From bc9577753ceb0a84f46358e5d3478aabe35cdbed Mon Sep 17 00:00:00 2001 From: roadiz-ci Date: Wed, 6 Nov 2024 00:33:07 +0000 Subject: [PATCH] refactor: Use friendsofphp/php-cs-fixer instead of squizlabs/php_codesniffer (#22) --- .github/workflows/run-test.yml | 2 -- .gitignore | 4 --- Makefile | 3 -- composer.json | 3 +- phpcs.xml.dist | 13 -------- .../PurgeUserValidationTokenCommand.php | 3 +- .../DoctrineMigrationCompilerPass.php | 20 +++-------- src/DependencyInjection/Configuration.php | 1 + .../RoadizUserExtension.php | 5 +-- src/Entity/UserMetadata.php | 24 ++------------ src/Entity/UserValidationToken.php | 33 +++---------------- ...ssAuthenticationSuccessEventSubscriber.php | 3 -- .../PasswordlessUserSignedUpSubscriber.php | 7 ++-- .../UserSignedUpSubscriber.php | 7 ++-- src/Manager/UserMetadataManager.php | 1 + src/Manager/UserMetadataManagerInterface.php | 1 + src/Manager/UserValidationTokenManager.php | 13 ++++---- .../UserValidationTokenManagerInterface.php | 1 + .../UserValidationTokenRepository.php | 1 + src/Security/FrontendLoginLinkHandler.php | 16 +++------ src/State/RecaptchaProtectedTrait.php | 7 ++-- src/State/SignupProcessorTrait.php | 1 + src/State/UserPasswordRequestProcessor.php | 11 ++++--- src/State/UserPasswordResetProcessor.php | 2 +- src/State/UserTokenProvider.php | 1 + src/State/UserValidationRequestProcessor.php | 4 +-- src/State/UserValidationTokenProcessor.php | 4 +-- 27 files changed, 54 insertions(+), 137 deletions(-) delete mode 100644 Makefile delete mode 100644 phpcs.xml.dist diff --git a/.github/workflows/run-test.yml b/.github/workflows/run-test.yml index 5b0323a..3b9abf4 100644 --- a/.github/workflows/run-test.yml +++ b/.github/workflows/run-test.yml @@ -35,7 +35,5 @@ jobs: ${{ runner.os }}-php-${{ matrix.php-version }}- - name: Install Dependencies run: composer install --no-scripts --no-ansi --no-interaction --no-progress - - name: Run PHP Code Sniffer - run: vendor/bin/phpcs -p ./src - name: Run PHPStan run: vendor/bin/phpstan analyse --no-progress -c phpstan.neon diff --git a/.gitignore b/.gitignore index e36c4c5..63e53f9 100644 --- a/.gitignore +++ b/.gitignore @@ -118,9 +118,5 @@ modules.xml /lib/ /.data/ -###> squizlabs/php_codesniffer ### -/.phpcs-cache -/phpcs.xml -###< squizlabs/php_codesniffer ### /report.txt /composer.lock diff --git a/Makefile b/Makefile deleted file mode 100644 index 16ef814..0000000 --- a/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -test: - php -d "memory_limit=-1" vendor/bin/phpcbf --report=full --report-file=./report.txt -p ./src - php -d "memory_limit=-1" vendor/bin/phpstan analyse -c phpstan.neon diff --git a/composer.json b/composer.json index 466fd98..cd33e81 100644 --- a/composer.json +++ b/composer.json @@ -35,8 +35,7 @@ "roadiz/doc-generator": "2.4.x-dev", "roadiz/entity-generator": "2.4.x-dev", "roadiz/jwt": "2.4.x-dev", - "roadiz/random": "2.4.x-dev", - "squizlabs/php_codesniffer": "^3.5" + "roadiz/random": "2.4.x-dev" }, "config": { "optimize-autoloader": true, diff --git a/phpcs.xml.dist b/phpcs.xml.dist deleted file mode 100644 index 19bff0c..0000000 --- a/phpcs.xml.dist +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - src/ - diff --git a/src/Console/PurgeUserValidationTokenCommand.php b/src/Console/PurgeUserValidationTokenCommand.php index 9dd0140..739f642 100644 --- a/src/Console/PurgeUserValidationTokenCommand.php +++ b/src/Console/PurgeUserValidationTokenCommand.php @@ -13,7 +13,7 @@ final class PurgeUserValidationTokenCommand extends Command { - public function __construct(private readonly ManagerRegistry $managerRegistry, string $name = null) + public function __construct(private readonly ManagerRegistry $managerRegistry, ?string $name = null) { parent::__construct($name); } @@ -32,6 +32,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $count = $this->managerRegistry->getRepository(UserValidationToken::class)->deleteAllExpired(); $io->success(sprintf('%d expired user validation token(s) were deleted.', $count)); + return 0; } } diff --git a/src/DependencyInjection/Compiler/DoctrineMigrationCompilerPass.php b/src/DependencyInjection/Compiler/DoctrineMigrationCompilerPass.php index 431bb45..5bc9ede 100644 --- a/src/DependencyInjection/Compiler/DoctrineMigrationCompilerPass.php +++ b/src/DependencyInjection/Compiler/DoctrineMigrationCompilerPass.php @@ -4,15 +4,11 @@ namespace RZ\Roadiz\UserBundle\DependencyInjection\Compiler; -use RuntimeException; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; class DoctrineMigrationCompilerPass implements CompilerPassInterface { - /** - * @inheritDoc - */ public function process(ContainerBuilder $container): void { if ($container->hasDefinition('doctrine.migrations.configuration')) { @@ -27,13 +23,13 @@ public function process(ContainerBuilder $container): void private function checkIfBundleRelativePath(string $path, ContainerBuilder $container): string { - if (isset($path[0]) && $path[0] === '@') { - $pathParts = explode('/', $path); + if (isset($path[0]) && '@' === $path[0]) { + $pathParts = explode('/', $path); $bundleName = \mb_substr($pathParts[0], 1); $bundlePath = $this->getBundlePath($bundleName, $container); - return $bundlePath . \mb_substr($path, \mb_strlen('@' . $bundleName)); + return $bundlePath.\mb_substr($path, \mb_strlen('@'.$bundleName)); } return $path; @@ -44,14 +40,8 @@ private function getBundlePath(string $bundleName, ContainerBuilder $container): $bundleMetadata = $container->getParameter('kernel.bundles_metadata'); assert(is_array($bundleMetadata)); - if (! isset($bundleMetadata[$bundleName])) { - throw new RuntimeException( - sprintf( - 'The bundle "%s" has not been registered, available bundles: %s', - $bundleName, - implode(', ', array_keys($bundleMetadata)) - ) - ); + if (!isset($bundleMetadata[$bundleName])) { + throw new \RuntimeException(sprintf('The bundle "%s" has not been registered, available bundles: %s', $bundleName, implode(', ', array_keys($bundleMetadata)))); } return $bundleMetadata[$bundleName]['path']; diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 98bb736..9d74de3 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -58,6 +58,7 @@ public function getConfigTreeBuilder(): TreeBuilder ->scalarNode('email_validated_role_name') ->defaultValue('ROLE_EMAIL_VALIDATED') ->end(); + return $builder; } } diff --git a/src/DependencyInjection/RoadizUserExtension.php b/src/DependencyInjection/RoadizUserExtension.php index 8e694f2..4e98131 100644 --- a/src/DependencyInjection/RoadizUserExtension.php +++ b/src/DependencyInjection/RoadizUserExtension.php @@ -11,12 +11,9 @@ class RoadizUserExtension extends Extension { - /** - * @inheritDoc - */ public function load(array $configs, ContainerBuilder $container): void { - $loader = new YamlFileLoader($container, new FileLocator(dirname(__DIR__) . '/../config')); + $loader = new YamlFileLoader($container, new FileLocator(dirname(__DIR__).'/../config')); $loader->load('services.yaml'); $configuration = new Configuration(); diff --git a/src/Entity/UserMetadata.php b/src/Entity/UserMetadata.php index 5a05658..8733b38 100644 --- a/src/Entity/UserMetadata.php +++ b/src/Entity/UserMetadata.php @@ -23,57 +23,39 @@ class UserMetadata #[ORM\Column(name: 'metadata', type: 'json', nullable: true)] private ?array $metadata = []; - /** - * @return int|null - */ public function getId(): ?int { return $this->id; } - /** - * @param int $id - * @return UserMetadata - */ public function setId(int $id): UserMetadata { $this->id = $id; + return $this; } - /** - * @return User|null - */ public function getUser(): ?User { return $this->user; } - /** - * @param User|null $user - * @return UserMetadata - */ public function setUser(?User $user): UserMetadata { $this->user = $user; + return $this; } - /** - * @return array|null - */ public function getMetadata(): ?array { return $this->metadata; } - /** - * @param array|null $metadata - * @return UserMetadata - */ public function setMetadata(?array $metadata): UserMetadata { $this->metadata = $metadata; + return $this; } } diff --git a/src/Entity/UserValidationToken.php b/src/Entity/UserValidationToken.php index 87bf734..129355b 100644 --- a/src/Entity/UserValidationToken.php +++ b/src/Entity/UserValidationToken.php @@ -33,76 +33,51 @@ class UserValidationToken #[ORM\Column(name: 'token_valid_until', type: 'datetime', unique: false, nullable: true)] private ?\DateTime $tokenValidUntil = null; - /** - * @return int - */ public function getId(): int { return $this->id; } - /** - * @param int $id - * @return UserValidationToken - */ public function setId(int $id): UserValidationToken { $this->id = $id; + return $this; } - - /** - * @return UserInterface|null - */ public function getUser(): ?UserInterface { return $this->user; } - /** - * @param UserInterface|null $user - * @return UserValidationToken - */ public function setUser(?UserInterface $user): UserValidationToken { $this->user = $user; + return $this; } - /** - * @return string - */ public function getToken(): string { return $this->token; } - /** - * @param string $token - * @return UserValidationToken - */ public function setToken(string $token): UserValidationToken { $this->token = $token; + return $this; } - /** - * @return \DateTime|null - */ public function getTokenValidUntil(): ?\DateTime { return $this->tokenValidUntil; } - /** - * @param \DateTime|null $tokenValidUntil - * @return UserValidationToken - */ public function setTokenValidUntil(?\DateTime $tokenValidUntil): UserValidationToken { $this->tokenValidUntil = $tokenValidUntil; + return $this; } } diff --git a/src/EventSubscriber/PasswordlessAuthenticationSuccessEventSubscriber.php b/src/EventSubscriber/PasswordlessAuthenticationSuccessEventSubscriber.php index 22d0c5f..198cac5 100644 --- a/src/EventSubscriber/PasswordlessAuthenticationSuccessEventSubscriber.php +++ b/src/EventSubscriber/PasswordlessAuthenticationSuccessEventSubscriber.php @@ -24,9 +24,6 @@ public function __construct( ) { } - /** - * @inheritDoc - */ public static function getSubscribedEvents(): array { return [ diff --git a/src/EventSubscriber/PasswordlessUserSignedUpSubscriber.php b/src/EventSubscriber/PasswordlessUserSignedUpSubscriber.php index 9dbd590..1aa7059 100644 --- a/src/EventSubscriber/PasswordlessUserSignedUpSubscriber.php +++ b/src/EventSubscriber/PasswordlessUserSignedUpSubscriber.php @@ -11,17 +11,14 @@ final readonly class PasswordlessUserSignedUpSubscriber implements EventSubscriberInterface { public function __construct( - private UserValidationTokenManagerInterface $userValidationTokenManager + private UserValidationTokenManagerInterface $userValidationTokenManager, ) { } - /** - * @inheritDoc - */ public static function getSubscribedEvents(): array { return [ - PasswordlessUserSignedUp::class => 'onUserSignedUp' + PasswordlessUserSignedUp::class => 'onUserSignedUp', ]; } diff --git a/src/EventSubscriber/UserSignedUpSubscriber.php b/src/EventSubscriber/UserSignedUpSubscriber.php index 4e72bc0..092c6af 100644 --- a/src/EventSubscriber/UserSignedUpSubscriber.php +++ b/src/EventSubscriber/UserSignedUpSubscriber.php @@ -11,17 +11,14 @@ final class UserSignedUpSubscriber implements EventSubscriberInterface { public function __construct( - private readonly UserValidationTokenManagerInterface $userValidationTokenManager + private readonly UserValidationTokenManagerInterface $userValidationTokenManager, ) { } - /** - * @inheritDoc - */ public static function getSubscribedEvents(): array { return [ - UserSignedUp::class => 'onUserSignedUp' + UserSignedUp::class => 'onUserSignedUp', ]; } diff --git a/src/Manager/UserMetadataManager.php b/src/Manager/UserMetadataManager.php index fe6609d..f9dc858 100644 --- a/src/Manager/UserMetadataManager.php +++ b/src/Manager/UserMetadataManager.php @@ -24,6 +24,7 @@ public function createMetadataForUser(User $user): UserMetadata $userMetadata = new UserMetadata(); $userMetadata->setUser($user); $this->managerRegistry->getManager()->persist($userMetadata); + return $userMetadata; } } diff --git a/src/Manager/UserMetadataManagerInterface.php b/src/Manager/UserMetadataManagerInterface.php index 20c5dc6..a161c1f 100644 --- a/src/Manager/UserMetadataManagerInterface.php +++ b/src/Manager/UserMetadataManagerInterface.php @@ -10,5 +10,6 @@ interface UserMetadataManagerInterface { public function getMetadataForUser(User $user): ?UserMetadata; + public function createMetadataForUser(User $user): UserMetadata; } diff --git a/src/Manager/UserValidationTokenManager.php b/src/Manager/UserValidationTokenManager.php index 5111b47..3f228d7 100644 --- a/src/Manager/UserValidationTokenManager.php +++ b/src/Manager/UserValidationTokenManager.php @@ -30,7 +30,7 @@ public function __construct( private RoleHierarchyInterface $roleHierarchy, private string $emailValidatedRoleName, private int $userValidationExpiresIn, - private string $userValidationUrl + private string $userValidationUrl, ) { } @@ -54,17 +54,18 @@ public function createForUser(UserInterface $user, bool $sendEmail = true): User if ($sendEmail) { $this->sendUserValidationEmail($existingValidationToken); } + return $existingValidationToken; } public function isUserEmailValidated(UserInterface $user): bool { $reachableRoles = $this->roleHierarchy->getReachableRoleNames($user->getRoles()); - return \in_array($this->emailValidatedRoleName, $reachableRoles) || - \in_array('ROLE_SUPER_ADMIN', $reachableRoles) || - \in_array('ROLE_SUPERADMIN', $reachableRoles); - } + return \in_array($this->emailValidatedRoleName, $reachableRoles) + || \in_array('ROLE_SUPER_ADMIN', $reachableRoles) + || \in_array('ROLE_SUPERADMIN', $reachableRoles); + } private function sendUserValidationEmail(UserValidationToken $userValidationToken): void { @@ -92,7 +93,7 @@ private function sendUserValidationEmail(UserValidationToken $userValidationToke UrlGeneratorInterface::ABSOLUTE_URL ); } catch (RouteNotFoundException $exception) { - $validationLink = $this->userValidationUrl . '?' . http_build_query( + $validationLink = $this->userValidationUrl.'?'.http_build_query( [ 'token' => $userValidationToken->getToken(), '_locale' => $user->getLocale(), diff --git a/src/Manager/UserValidationTokenManagerInterface.php b/src/Manager/UserValidationTokenManagerInterface.php index 5378f17..4084c09 100644 --- a/src/Manager/UserValidationTokenManagerInterface.php +++ b/src/Manager/UserValidationTokenManagerInterface.php @@ -10,5 +10,6 @@ interface UserValidationTokenManagerInterface { public function createForUser(UserInterface $user, bool $sendEmail = true): UserValidationToken; + public function isUserEmailValidated(UserInterface $user): bool; } diff --git a/src/Repository/UserValidationTokenRepository.php b/src/Repository/UserValidationTokenRepository.php index a8c1f16..9eed654 100644 --- a/src/Repository/UserValidationTokenRepository.php +++ b/src/Repository/UserValidationTokenRepository.php @@ -22,6 +22,7 @@ public function deleteAllExpired(): int public function findOneByValidToken(string $token): ?UserValidationToken { $qb = $this->createQueryBuilder('t'); + return $qb->andWhere($qb->expr()->eq('t.token', ':token')) ->andWhere($qb->expr()->gte('t.tokenValidUntil', ':now')) ->setParameter('token', $token) diff --git a/src/Security/FrontendLoginLinkHandler.php b/src/Security/FrontendLoginLinkHandler.php index ffdfc7a..eb37554 100644 --- a/src/Security/FrontendLoginLinkHandler.php +++ b/src/Security/FrontendLoginLinkHandler.php @@ -22,20 +22,17 @@ public function __construct( private string $frontendLoginCheckRoute, private SignatureHasher $signatureHasher, private array $frontendLoginLinkRequestRoutes, - array $options = [] + array $options = [], ) { $this->options = array_merge([ 'lifetime' => 600, ], $options); } - /** - * @inheritDoc - */ public function createLoginLink( UserInterface $user, ?Request $request = null, - int $lifetime = null + ?int $lifetime = null, ): LoginLinkDetails { if (null === $request) { throw new \InvalidArgumentException('Request cannot be null.'); @@ -48,7 +45,7 @@ public function createLoginLink( } $expires = time() + ($lifetime ?: $this->options['lifetime']); - $expiresAt = new \DateTimeImmutable('@' . $expires); + $expiresAt = new \DateTimeImmutable('@'.$expires); $parameters = [ 'user' => $user->getUserIdentifier(), @@ -60,18 +57,15 @@ public function createLoginLink( $parameters['redirect'] = $redirect; } - $url = $this->frontendLoginCheckRoute . '?' . http_build_query($parameters); + $url = $this->frontendLoginCheckRoute.'?'.http_build_query($parameters); - if (filter_var($url, FILTER_VALIDATE_URL) === false) { + if (false === filter_var($url, FILTER_VALIDATE_URL)) { throw new \InvalidArgumentException(sprintf('The URL "%s" is not valid.', $url)); } return new LoginLinkDetails($url, $expiresAt); } - /** - * @inheritDoc - */ public function consumeLoginLink(Request $request): UserInterface { return $this->decorated->consumeLoginLink($request); diff --git a/src/State/RecaptchaProtectedTrait.php b/src/State/RecaptchaProtectedTrait.php index 76f4d4b..c157087 100644 --- a/src/State/RecaptchaProtectedTrait.php +++ b/src/State/RecaptchaProtectedTrait.php @@ -11,6 +11,7 @@ trait RecaptchaProtectedTrait { abstract protected function getRecaptchaHeaderName(): string; + abstract protected function getRecaptchaService(): RecaptchaServiceInterface; protected function validateRecaptchaHeader(Request $request): void @@ -21,11 +22,11 @@ protected function validateRecaptchaHeader(Request $request): void } if (true !== $response = $this->getRecaptchaService()->check($responseValue)) { if (\is_string($response)) { - throw new BadRequestHttpException($this->getRecaptchaHeaderName() . ': ' . $response); + throw new BadRequestHttpException($this->getRecaptchaHeaderName().': '.$response); } elseif (\is_array($response)) { - throw new BadRequestHttpException($this->getRecaptchaHeaderName() . ': ' . reset($response)); + throw new BadRequestHttpException($this->getRecaptchaHeaderName().': '.reset($response)); } - throw new BadRequestHttpException($this->getRecaptchaHeaderName() . ': Recaptcha response is not valid.'); + throw new BadRequestHttpException($this->getRecaptchaHeaderName().': Recaptcha response is not valid.'); } } } diff --git a/src/State/SignupProcessorTrait.php b/src/State/SignupProcessorTrait.php index 8f942c8..f551ec4 100644 --- a/src/State/SignupProcessorTrait.php +++ b/src/State/SignupProcessorTrait.php @@ -15,6 +15,7 @@ trait SignupProcessorTrait { abstract protected function getSecurity(): Security; + abstract protected function getUserSignupLimiter(): RateLimiterFactory; protected function validateRequest(?Request $request): void diff --git a/src/State/UserPasswordRequestProcessor.php b/src/State/UserPasswordRequestProcessor.php index fdf1b63..7fa2588 100644 --- a/src/State/UserPasswordRequestProcessor.php +++ b/src/State/UserPasswordRequestProcessor.php @@ -45,7 +45,7 @@ public function __construct( private UrlGeneratorInterface $urlGenerator, private RecaptchaServiceInterface $recaptchaService, private string $passwordResetUrl, - private string $recaptchaHeaderName = 'x-g-recaptcha-response' + private string $recaptchaHeaderName = 'x-g-recaptcha-response', ) { } @@ -118,6 +118,7 @@ private function getUser(string $identifier): ?User } } catch (AuthenticationException $exception) { } + return null; } @@ -140,11 +141,11 @@ private function sendPasswordResetLink(Request $request, User $user): void UrlGeneratorInterface::ABSOLUTE_URL ); } catch (RouteNotFoundException $exception) { - $resetLink = $this->passwordResetUrl . '?' . http_build_query( + $resetLink = $this->passwordResetUrl.'?'.http_build_query( [ - 'token' => $user->getConfirmationToken(), - '_locale' => $request->getLocale(), - ] + 'token' => $user->getConfirmationToken(), + '_locale' => $request->getLocale(), + ] ); } diff --git a/src/State/UserPasswordResetProcessor.php b/src/State/UserPasswordResetProcessor.php index 8d6e67e..51e947c 100644 --- a/src/State/UserPasswordResetProcessor.php +++ b/src/State/UserPasswordResetProcessor.php @@ -27,7 +27,7 @@ public function __construct( private ValidatorInterface $validator, private RateLimiterFactory $passwordResetLimiter, private RequestStack $requestStack, - private int $passwordResetExpiresIn + private int $passwordResetExpiresIn, ) { } diff --git a/src/State/UserTokenProvider.php b/src/State/UserTokenProvider.php index 0b28dca..0b133f2 100644 --- a/src/State/UserTokenProvider.php +++ b/src/State/UserTokenProvider.php @@ -54,6 +54,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c } $userOutput->emailValidated = $this->userValidationTokenManager->isUserEmailValidated($user); + return $userOutput; } } diff --git a/src/State/UserValidationRequestProcessor.php b/src/State/UserValidationRequestProcessor.php index 7ee766b..15a93d2 100644 --- a/src/State/UserValidationRequestProcessor.php +++ b/src/State/UserValidationRequestProcessor.php @@ -12,9 +12,9 @@ use RZ\Roadiz\UserBundle\Api\Dto\UserValidationRequestInput; use RZ\Roadiz\UserBundle\Api\Dto\VoidOutput; use RZ\Roadiz\UserBundle\Manager\UserValidationTokenManagerInterface; +use Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException; -use Symfony\Bundle\SecurityBundle\Security; final readonly class UserValidationRequestProcessor implements ProcessorInterface { @@ -23,7 +23,7 @@ public function __construct( private Security $security, private UserValidationTokenManagerInterface $userValidationTokenManager, private ManagerRegistry $managerRegistry, - private string $emailValidatedRoleName + private string $emailValidatedRoleName, ) { } diff --git a/src/State/UserValidationTokenProcessor.php b/src/State/UserValidationTokenProcessor.php index 65713bf..c20752a 100644 --- a/src/State/UserValidationTokenProcessor.php +++ b/src/State/UserValidationTokenProcessor.php @@ -13,9 +13,9 @@ use RZ\Roadiz\UserBundle\Api\Dto\VoidOutput; use RZ\Roadiz\UserBundle\Entity\UserValidationToken; use RZ\Roadiz\UserBundle\Event\UserEmailValidated; +use Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException; -use Symfony\Bundle\SecurityBundle\Security; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; final readonly class UserValidationTokenProcessor implements ProcessorInterface @@ -25,7 +25,7 @@ public function __construct( private Roles $rolesBag, private Security $security, private EventDispatcherInterface $eventDispatcher, - private string $emailValidatedRoleName + private string $emailValidatedRoleName, ) { }