apply more cs rules for php-cs

This commit is contained in:
2023-10-17 13:27:03 +02:00
parent 0b0cbed9db
commit bc2041cbdd
1485 changed files with 8169 additions and 9620 deletions

View File

@@ -15,7 +15,6 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
use Symfony\Component\Security\Core\Security;
use UnexpectedValueException;
class AccompanyingPeriodCommentVoter extends Voter
{
@@ -35,7 +34,7 @@ class AccompanyingPeriodCommentVoter extends Voter
return match ($attribute) {
self::EDIT => $this->security->isGranted(AccompanyingPeriodVoter::EDIT, $subject->getAccompanyingPeriod()),
self::DELETE => $this->security->isGranted(AccompanyingPeriodVoter::EDIT, $subject->getAccompanyingPeriod()),
default => throw new UnexpectedValueException("This attribute {$attribute} is not supported"),
default => throw new \UnexpectedValueException("This attribute {$attribute} is not supported"),
};
}
}

View File

@@ -15,7 +15,6 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\Resource;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
use UnexpectedValueException;
class AccompanyingPeriodResourceVoter extends Voter
{
@@ -36,7 +35,7 @@ class AccompanyingPeriodResourceVoter extends Voter
[AccompanyingPeriodVoter::EDIT],
$subject->getAccompanyingPeriod()
),
default => throw new UnexpectedValueException("attribute not supported: {$attribute}"),
default => throw new \UnexpectedValueException("attribute not supported: {$attribute}"),
};
}
}

View File

@@ -23,8 +23,6 @@ use Chill\PersonBundle\Entity\Person;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Security;
use function in_array;
class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface
{
/**
@@ -103,7 +101,7 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
final public const TOGGLE_INTENSITY = 'CHILL_PERSON_ACCOMPANYING_PERIOD_TOGGLE_INTENSITY';
/**
* Right to see confidential period even if not referrer
* Right to see confidential period even if not referrer.
*/
final public const SEE_CONFIDENTIAL_ALL = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE_CONFIDENTIAL';
@@ -162,7 +160,7 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
if ($subject instanceof AccompanyingPeriod) {
if (AccompanyingPeriod::STEP_CLOSED === $subject->getStep()) {
if (in_array($attribute, [self::EDIT, self::DELETE], true)) {
if (\in_array($attribute, [self::EDIT, self::DELETE], true)) {
return false;
}
@@ -183,7 +181,7 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
return false;
}
if (in_array($attribute, [
if (\in_array($attribute, [
self::SEE, self::SEE_DETAILS, self::EDIT,
], true)) {
if ($subject->getUser() === $token->getUser()) {

View File

@@ -15,7 +15,6 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluatio
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
use UnexpectedValueException;
/**
* Voter for AccompanyingPeriodWorkEvaluationDocument.
@@ -35,7 +34,7 @@ class AccompanyingPeriodWorkEvaluationDocumentVoter extends Voter
}
/**
* @param string $attribute
* @param string $attribute
* @param AccompanyingPeriodWorkEvaluationDocument $subject
*
* @return bool|void
@@ -48,7 +47,7 @@ class AccompanyingPeriodWorkEvaluationDocumentVoter extends Voter
[AccompanyingPeriodWorkEvaluationVoter::SEE],
$subject->getAccompanyingPeriodWorkEvaluation()
),
default => throw new UnexpectedValueException("The attribute {$attribute} is not supported"),
default => throw new \UnexpectedValueException("The attribute {$attribute} is not supported"),
};
}
}

View File

@@ -16,8 +16,6 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluatio
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
use Symfony\Component\Security\Core\Security;
use UnexpectedValueException;
use function in_array;
class AccompanyingPeriodWorkEvaluationVoter extends Voter implements ChillVoterInterface
{
@@ -35,11 +33,11 @@ class AccompanyingPeriodWorkEvaluationVoter extends Voter implements ChillVoterI
protected function supports($attribute, $subject)
{
return $subject instanceof AccompanyingPeriodWorkEvaluation
&& in_array($attribute, self::ALL, true);
&& \in_array($attribute, self::ALL, true);
}
/**
* @param string $attribute
* @param string $attribute
* @param AccompanyingPeriodWorkEvaluation $subject
*/
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
@@ -47,7 +45,7 @@ class AccompanyingPeriodWorkEvaluationVoter extends Voter implements ChillVoterI
return match ($attribute) {
self::STATS => $this->security->isGranted(AccompanyingPeriodVoter::STATS, $subject),
self::SEE => $this->security->isGranted(AccompanyingPeriodWorkVoter::SEE, $subject->getAccompanyingPeriodWork()),
default => throw new UnexpectedValueException("attribute {$attribute} is not supported"),
default => throw new \UnexpectedValueException("attribute {$attribute} is not supported"),
};
}
}

View File

@@ -21,9 +21,6 @@ use Chill\PersonBundle\Entity\Person;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
use Symfony\Component\Security\Core\Security;
use UnexpectedValueException;
use function get_class;
use function in_array;
class AccompanyingPeriodWorkVoter extends Voter implements ProvideRoleHierarchyInterface, ChillVoterInterface
{
@@ -81,15 +78,15 @@ class AccompanyingPeriodWorkVoter extends Voter implements ProvideRoleHierarchyI
return
(
$subject instanceof AccompanyingPeriodWork
&& in_array($attribute, $this->getRoles(), true)
&& \in_array($attribute, $this->getRoles(), true)
) || (
$subject instanceof AccompanyingPeriod
&& in_array($attribute, [self::SEE, self::CREATE], true)
&& \in_array($attribute, [self::SEE, self::CREATE], true)
);
}
/**
* @param string $attribute
* @param string $attribute
* @param AccompanyingPeriodWork $subject
*/
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
@@ -98,19 +95,16 @@ class AccompanyingPeriodWorkVoter extends Voter implements ProvideRoleHierarchyI
return match ($attribute) {
self::SEE => $this->security->isGranted(AccompanyingPeriodVoter::SEE_DETAILS, $subject->getAccompanyingPeriod()),
self::CREATE, self::UPDATE, self::DELETE => $this->security->isGranted(AccompanyingPeriodVoter::EDIT, $subject->getAccompanyingPeriod()),
default => throw new UnexpectedValueException("attribute {$attribute} is not supported"),
default => throw new \UnexpectedValueException("attribute {$attribute} is not supported"),
};
} elseif ($subject instanceof AccompanyingPeriod) {
return match ($attribute) {
self::SEE => $this->security->isGranted(AccompanyingPeriodVoter::SEE_DETAILS, $subject),
self::CREATE => $this->security->isGranted(AccompanyingPeriodVoter::CREATE, $subject),
default => throw new UnexpectedValueException(sprintf(
"attribute {$attribute} is not supported on instance %s",
AccompanyingPeriod::class
)),
default => throw new \UnexpectedValueException(sprintf("attribute {$attribute} is not supported on instance %s", AccompanyingPeriod::class)),
};
}
throw new UnexpectedValueException(sprintf("attribute {$attribute} on instance %s is not supported", $subject::class));
throw new \UnexpectedValueException(sprintf("attribute {$attribute} on instance %s is not supported", $subject::class));
}
}

View File

@@ -21,8 +21,6 @@ use Chill\PersonBundle\Entity\Household\HouseholdMember;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
use Symfony\Component\Security\Core\Security;
use UnexpectedValueException;
use function in_array;
class HouseholdVoter extends Voter implements ProvideRoleHierarchyInterface, ChillVoterInterface
{
@@ -71,7 +69,7 @@ class HouseholdVoter extends Voter implements ProvideRoleHierarchyInterface, Chi
protected function supports($attribute, $subject)
{
return ($subject instanceof Household
&& in_array($attribute, self::ALL, true))
&& \in_array($attribute, self::ALL, true))
|| $this->helper->supports($attribute, $subject);
}
@@ -81,7 +79,7 @@ class HouseholdVoter extends Voter implements ProvideRoleHierarchyInterface, Chi
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'),
default => throw new \UnexpectedValueException('attribute not supported'),
};
}