diff --git a/phpstan-baseline-level-4.neon b/phpstan-baseline-level-4.neon index 1b7bb5a07..833a55afb 100644 --- a/phpstan-baseline-level-4.neon +++ b/phpstan-baseline-level-4.neon @@ -2631,11 +2631,6 @@ parameters: count: 2 path: src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php - - - message: "#^Call to method getRoleScopes\\(\\) on an unknown class Chill\\\\MainBundle\\\\Entity\\\\PermissionGroup\\.$#" - count: 1 - path: src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php - - message: "#^Empty array passed to foreach\\.$#" count: 1 diff --git a/src/Bundle/ChillMainBundle/Entity/GroupCenter.php b/src/Bundle/ChillMainBundle/Entity/GroupCenter.php index c2e62d012..01b450394 100644 --- a/src/Bundle/ChillMainBundle/Entity/GroupCenter.php +++ b/src/Bundle/ChillMainBundle/Entity/GroupCenter.php @@ -31,7 +31,7 @@ class GroupCenter * ) * @ORM\Cache(usage="NONSTRICT_READ_WRITE") */ - private $center; + private ?Center $center = null; /** * @var int @@ -40,83 +40,64 @@ class GroupCenter * @ORM\Column(name="id", type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ - private $id; + private ?int $id = null; /** - * @var PermissionsGroup - * * @ORM\ManyToOne( * targetEntity="Chill\MainBundle\Entity\PermissionsGroup", * inversedBy="groupCenters") * @ORM\Cache(usage="NONSTRICT_READ_WRITE") */ - private $permissionsGroup; + private ?PermissionsGroup $permissionsGroup = null; /** - * @var Collection - * * @ORM\ManyToMany( * targetEntity="Chill\MainBundle\Entity\User", * mappedBy="groupCenters" * ) + * @var Collection */ - private $users; + private Collection $users; /** * GroupCenter constructor. */ public function __construct() { - $this->permissionsGroup = new ArrayCollection(); $this->users = new ArrayCollection(); } - /** - * @return Center - */ - public function getCenter() + public function getCenter(): ?Center { return $this->center; } - /** - * @return int - */ - public function getId() + public function getId(): ?int { return $this->id; } - /** - * @return PermissionGroup - */ - public function getPermissionsGroup() + public function getPermissionsGroup(): ?PermissionsGroup { return $this->permissionsGroup; } /** - * @return ArrayCollection|Collection + * @return Collection */ - public function getUsers() + public function getUsers(): Collection { return $this->users; } - /** - * @return \Chill\MainBundle\Entity\GroupCenter - */ - public function setCenter(Center $center) + public function setCenter(Center $center): self { $this->center = $center; return $this; } - /** - * @return \Chill\MainBundle\Entity\GroupCenter - */ - public function setPermissionsGroup(PermissionsGroup $permissionsGroup) + public function setPermissionsGroup(PermissionsGroup $permissionsGroup): self { $this->permissionsGroup = $permissionsGroup; diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php index 828f53757..1105c9d8a 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php @@ -120,6 +120,11 @@ class AuthorizationHelper implements AuthorizationHelperInterface if ($role instanceof Role) { $role = $role->getRole(); } + + if (!$user instanceof User) { + return []; + } + /** @var array $centers */ $centers = [];