diff --git a/data/FlatRole.php.dist b/data/FlatRole.php.dist index 67d97ac0..6b90c28c 100644 --- a/data/FlatRole.php.dist +++ b/data/FlatRole.php.dist @@ -23,38 +23,21 @@ use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Laminas\Permissions\Rbac\RoleInterface; -/** - * @ORM\Entity - * @ORM\Table(name="roles") - */ #[ORM\Entity] #[ORM\Table(name: 'roles')] +/** + * @deprecated + */ class FlatRole implements RoleInterface { - /** - * @var int|null - * - * @ORM\Id - * @ORM\Column(type="integer") - * @ORM\GeneratedValue(strategy="AUTO") - */ #[ORM\Id] #[ORM\Column(name: 'id', type: 'integer')] #[ORM\GeneratedValue(strategy: 'AUTO')] protected ?int $id; - /** - * @var string - * - * @ORM\Column(type="string", length=255, unique=true) - */ #[ORM\Column(name: 'name', type: 'string', length: 255, unique: true)] protected string $name = ''; - /** - * @var Permission[]|Collection - * @ORM\ManyToMany(targetEntity="Permission", indexBy="name", fetch="EAGER", cascade={"persist"}) - */ #[ORM\ManyToMany(targetEntity: "Persmission", cascade: ["persist"], fetch: "EAGER", indexBy: "name")] protected array|Collection|ArrayCollection $permissions; diff --git a/data/HierarchicalRole.php.dist b/data/HierarchicalRole.php.dist index 560b4701..430b7147 100644 --- a/data/HierarchicalRole.php.dist +++ b/data/HierarchicalRole.php.dist @@ -23,46 +23,29 @@ use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Laminas\Permissions\Rbac\RoleInterface; -/** - * @ORM\Entity - * @ORM\Table(name="roles") - */ #[ORM\Entity] #[ORM\Table(name: 'roles')] +/** + * @deprecated + */ class HierarchicalRole implements RoleInterface { - /** - * @var int|null - * - * @ORM\Id - * @ORM\Column(type="integer") - * @ORM\GeneratedValue(strategy="AUTO") - */ #[ORM\Id] #[ORM\Column(name: 'id', type: 'integer')] #[ORM\GeneratedValue(strategy: 'AUTO')] protected ?int $id = null; - /** - * @var string - * - * @ORM\Column(type="string", length=48, unique=true) - */ #[ORM\Column(name: 'name', type: 'string', length: 255, unique: true)] protected string $name = ''; /** * @var RoleInterface[]|Collection - * - * @ORM\ManyToMany(targetEntity="HierarchicalRole") */ #[ORM\ManyToMany(targetEntity: RoleInterface::class)] protected array|Collection|ArrayCollection $children = []; /** * @var Permission[]|Collection - * - * @ORM\ManyToMany(targetEntity="Permission", indexBy="name", fetch="EAGER") */ #[ORM\ManyToMany(targetEntity: Permission::class, fetch: 'EAGER', indexBy: 'name')] protected array|Collection|ArrayCollection $permissions; diff --git a/data/Permission.php.dist b/data/Permission.php.dist index 2f986f9b..f3c101ef 100644 --- a/data/Permission.php.dist +++ b/data/Permission.php.dist @@ -20,31 +20,18 @@ declare(strict_types=1); use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity - * @ORM\Table(name="permissions") - */ #[ORM\Entity] #[ORM\Table(name: 'permissions')] +/** + * @deprecated + */ class Permission { - /** - * @var int|null - * - * @ORM\Id - * @ORM\Column(type="integer") - * @ORM\GeneratedValue(strategy="AUTO") - */ #[ORM\Id] #[ORM\Column(type: 'integer')] #[ORM\GeneratedValue(strategy: 'AUTO')] protected ?int $id; - /** - * @var string - * - * @ORM\Column(type="string", length=128, unique=true) - */ #[ORM\Column(type: 'string', length: 128, unique: true)] protected string $name = ''; diff --git a/data/Role.php.dist b/data/Role.php.dist index d5e3c3b0..bd958d5f 100644 --- a/data/Role.php.dist +++ b/data/Role.php.dist @@ -24,52 +24,26 @@ use Doctrine\ORM\Mapping as ORM; use Laminas\Permissions\Rbac\RoleInterface; /** - * @ORM\Entity - * @ORM\Table(name="roles") + * @deprecated */ #[ORM\Entity] #[ORM\Table(name: 'roles')] class Role implements RoleInterface { - /** - * @var int|null - * - * @ORM\Id - * @ORM\Column(type="integer") - * @ORM\GeneratedValue(strategy="AUTO") - */ #[ORM\Id] #[ORM\Column(type: 'integer')] #[ORM\GeneratedValue] private ?int $id; - /** - * @var string|null - * - * @ORM\Column(type="string", length=32, unique=true) - */ #[ORM\Column(type: 'string', length: 32, unique: true)] private ?string $name; - /** - * @var Collection - * - * @ORM\JoinTable(name="role_children") - * @ORM\JoinColumn(name="parent_id", referencedColumnName="id") - * @ORM\InverseJoinColumn(name="child_id", referencedColumnName="id") - * @ORM\ManyToMany(targetEntity="role", cascade={"persist"}) - */ #[ORM\JoinTable(name: 'role_children')] #[ORM\JoinColumn(name: 'parent_id', referencedColumnName: 'id')] #[ORM\InverseJoinColumn(name: 'child_id', referencedColumnName: 'id')] #[ORM\ManyToMany(targetEntity: 'Role', cascade: ['persist'])] private Collection $children; - /** - * @var Collection - * - * @ORM\ManyToMany(targetEntity="Permission", indexBy="name", fetch="EAGER", cascade={"persist"}) - */ #[ORM\ManyToMany(targetEntity: 'Permission', cascade: ['persist'], fetch: 'EAGER', indexBy: 'name')] private Collection $permissions; diff --git a/psalm.baseline.xml b/psalm.baseline.xml index 0be527e7..6a2fb1d0 100644 --- a/psalm.baseline.xml +++ b/psalm.baseline.xml @@ -8,6 +8,12 @@ + + + + + + @@ -64,27 +70,20 @@ - - - - - - - - roleCache[$key]]]> - - - - - + + + + + + @@ -219,6 +218,10 @@ + + + + @@ -257,11 +260,46 @@ + + + + + + + + + + + + + + + getRepository(\LmcTest\Rbac\Asset\Role::class)]]> + getRepository(\LmcTest\Rbac\Asset\Role::class)]]> + getRepository(\LmcTest\Rbac\Asset\Role::class)]]> + + + + + + + + + + + + + + + + + + Driver::class, diff --git a/src/Role/ObjectRepositoryRoleProvider.php b/src/Role/ObjectRepositoryRoleProvider.php index 0b71482d..ed1b123f 100644 --- a/src/Role/ObjectRepositoryRoleProvider.php +++ b/src/Role/ObjectRepositoryRoleProvider.php @@ -22,6 +22,7 @@ namespace Lmc\Rbac\Role; use Doctrine\Persistence\ObjectRepository; +use Laminas\Permissions\Rbac\RoleInterface; use Lmc\Rbac\Exception\RoleNotFoundException; use function array_diff; @@ -31,17 +32,17 @@ /** * Role provider that uses Doctrine object repository to fetch roles + * + * @deprecated Use Lmc\Rbac\Role\Doctrine\ObjectRepositoryRoleProvider instead */ final class ObjectRepositoryRoleProvider implements RoleProviderInterface { - /** @var ObjectRepository */ - private $objectRepository; + private ObjectRepository $objectRepository; - /** @var string */ - private $roleNameProperty; + private string $roleNameProperty; - /** @var array */ - private $roleCache = []; + /** @var array */ + private array $roleCache = []; public function __construct(ObjectRepository $objectRepository, string $roleNameProperty) { diff --git a/src/Role/ObjectRepositoryRoleProviderFactory.php b/src/Role/ObjectRepositoryRoleProviderFactory.php index e4fde122..a6fb63e5 100644 --- a/src/Role/ObjectRepositoryRoleProviderFactory.php +++ b/src/Role/ObjectRepositoryRoleProviderFactory.php @@ -28,6 +28,8 @@ /** * Factory used to create an object repository role provider + * + * @deprecated */ class ObjectRepositoryRoleProviderFactory { diff --git a/test/Asset/Permission.php b/test/Asset/Permission.php index c96d6088..d980e79e 100644 --- a/test/Asset/Permission.php +++ b/test/Asset/Permission.php @@ -24,24 +24,17 @@ use Doctrine\ORM\Mapping as ORM; /** - * @ORM\Entity - * @ORM\Table(name="permissions") + * @deprecated */ #[ORM\Entity] #[ORM\Table(name: 'permissions')] class Permission { - /** - * @ORM\Id - * @ORM\Column(type="integer") - * @ORM\GeneratedValue(strategy="AUTO") - */ #[ORM\Id] #[ORM\Column(type: 'integer')] #[ORM\GeneratedValue(strategy: 'AUTO')] protected ?int $id; - /** @ORM\Column(type="string", length=128, unique=true) */ #[ORM\Column(type: 'string', length: 128, unique: true)] protected ?string $name; diff --git a/test/Asset/Role.php b/test/Asset/Role.php index 3e0a4894..f6e1f1b5 100644 --- a/test/Asset/Role.php +++ b/test/Asset/Role.php @@ -27,40 +27,26 @@ use Laminas\Permissions\Rbac\RoleInterface; /** - * @ORM\Entity - * @ORM\Table(name="roles") + * @deprecated */ #[ORM\Entity] #[ORM\Table(name: 'roles')] class Role implements RoleInterface { - /** - * @ORM\Id - * @ORM\Column(type="integer") - * @ORM\GeneratedValue(strategy="AUTO") - */ #[ORM\Id] #[ORM\Column(type: 'integer')] #[ORM\GeneratedValue] private ?int $id; - /** @ORM\Column(type="string", length=32, unique=true) */ #[ORM\Column(type: 'string', length: 32, unique: true)] private ?string $name; - /** - * @ORM\JoinTable(name="role_children") - * @ORM\JoinColumn(name="parent_id", referencedColumnName="id") - * @ORM\InverseJoinColumn(name="child_id", referencedColumnName="id") - * @ORM\ManyToMany(targetEntity="role", cascade={"persist"}) - */ #[ORM\JoinTable(name: 'role_children')] #[ORM\JoinColumn(name: 'parent_id', referencedColumnName: 'id')] #[ORM\InverseJoinColumn(name: 'child_id', referencedColumnName: 'id')] #[ORM\ManyToMany(targetEntity: self::class, cascade: ['persist'])] private Collection $children; - /** @ORM\ManyToMany(targetEntity="Permission", indexBy="name", fetch="EAGER", cascade={"persist"}) */ #[ORM\ManyToMany(targetEntity: 'Permission', cascade: ['persist'], fetch: 'EAGER', indexBy: 'name')] private Collection $permissions; diff --git a/test/Role/ObjectRepositoryRoleProviderFactoryTest.php b/test/Role/ObjectRepositoryRoleProviderFactoryTest.php index c10e11f9..8e62c1b6 100644 --- a/test/Role/ObjectRepositoryRoleProviderFactoryTest.php +++ b/test/Role/ObjectRepositoryRoleProviderFactoryTest.php @@ -31,6 +31,9 @@ use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; +/** + * @deprecated + */ #[CoversClass(ObjectRepositoryRoleProviderFactory::class)] class ObjectRepositoryRoleProviderFactoryTest extends TestCase { diff --git a/test/Role/ObjectRepositoryRoleProviderTest.php b/test/Role/ObjectRepositoryRoleProviderTest.php index db40ba3a..7573cf27 100644 --- a/test/Role/ObjectRepositoryRoleProviderTest.php +++ b/test/Role/ObjectRepositoryRoleProviderTest.php @@ -43,6 +43,9 @@ use const PHP_VERSION_ID; +/** + * @deprecated + */ #[CoversClass(ObjectRepositoryRoleProvider::class)] class ObjectRepositoryRoleProviderTest extends TestCase {