DX: apply rector rules up to php8.0

This commit is contained in:
2023-04-15 01:05:37 +02:00
parent d8870e906f
commit dde3002100
714 changed files with 2348 additions and 9263 deletions

View File

@@ -45,11 +45,8 @@ class HouseholdVoter extends Voter implements ProvideRoleHierarchyInterface, Chi
private VoterHelperInterface $helper;
private Security $security;
public function __construct(Security $security, VoterHelperFactoryInterface $voterHelperFactory)
public function __construct(private Security $security, VoterHelperFactoryInterface $voterHelperFactory)
{
$this->security = $security;
$this->helper = $voterHelperFactory
->generate(self::class)
->addCheckFor(Center::class, [self::STATS])
@@ -80,19 +77,12 @@ class HouseholdVoter extends Voter implements ProvideRoleHierarchyInterface, Chi
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
{
switch ($attribute) {
case self::SEE:
return $this->checkAssociatedMembersRole($subject, PersonVoter::SEE);
case self::EDIT:
return $this->checkAssociatedMembersRole($subject, PersonVoter::UPDATE);
case self::STATS:
return $this->voteOnAttribute($attribute, $subject, $token);
default:
throw new UnexpectedValueException('attribute not supported');
}
return match ($attribute) {
self::SEE => $this->checkAssociatedMembersRole($subject, PersonVoter::SEE),
self::EDIT => $this->checkAssociatedMembersRole($subject, PersonVoter::UPDATE),
self::STATS => $this->voteOnAttribute($attribute, $subject, $token),
default => throw new UnexpectedValueException('attribute not supported'),
};
}
private function checkAssociatedMembersRole(Household $household, string $attribute): bool