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,13 +15,10 @@ use Chill\MainBundle\Entity\RoleScope;
use Chill\MainBundle\Security\RoleProvider;
use Chill\MainBundle\Validation\Constraint\RoleScopeScopePresenceConstraint;
use Psr\Log\LoggerInterface;
use RuntimeException;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Contracts\Translation\TranslatorInterface;
use function in_array;
class RoleScopeScopePresence extends ConstraintValidator
{
public function __construct(private readonly RoleProvider $roleProvider, private readonly LoggerInterface $logger, private readonly TranslatorInterface $translator) {}
@@ -29,19 +26,19 @@ class RoleScopeScopePresence extends ConstraintValidator
public function validate($value, Constraint $constraint)
{
if (!$value instanceof RoleScope) {
throw new RuntimeException('The validated object is not an instance of roleScope');
throw new \RuntimeException('The validated object is not an instance of roleScope');
}
if (!$constraint instanceof RoleScopeScopePresenceConstraint) {
throw new RuntimeException('This validator should be used with RoleScopScopePresenceConstraint');
throw new \RuntimeException('This validator should be used with RoleScopScopePresenceConstraint');
}
$this->logger->debug('begin validation of a role scope instance');
//if the role scope should have a scope
// if the role scope should have a scope
if (
!in_array($value->getRole(), $this->roleProvider->getRolesWithoutScopes(), true)
&& $value->getScope() === null
!\in_array($value->getRole(), $this->roleProvider->getRolesWithoutScopes(), true)
&& null === $value->getScope()
) {
$this->context->buildViolation($constraint->messagePresenceRequired)
->setParameter('%role%', $this->translator->trans($value->getRole()))
@@ -49,7 +46,7 @@ class RoleScopeScopePresence extends ConstraintValidator
$this->logger->debug('the role scope should have a scope, but scope is null. Violation build.');
} elseif // if the scope should be null
(
in_array($value->getRole(), $this->roleProvider->getRolesWithoutScopes(), true)
\in_array($value->getRole(), $this->roleProvider->getRolesWithoutScopes(), true)
&& null !== $value->getScope()
) {
$this->context->buildViolation($constraint->messageNullRequired)