diff --git a/src/Action/ResetAction.php b/src/Action/ResetAction.php index 392c38b73..92789f376 100644 --- a/src/Action/ResetAction.php +++ b/src/Action/ResetAction.php @@ -51,7 +51,7 @@ public function __invoke(Request $request, string $token): Response $user = $this->userManager->findUserByConfirmationToken($token); if (null === $user) { - throw new NotFoundHttpException(sprintf('The user with "confirmation token" does not exist for value "%s"', $token)); + throw new NotFoundHttpException(\sprintf('The user with "confirmation token" does not exist for value "%s"', $token)); } if (!$user->isPasswordRequestNonExpired($this->tokenTtl)) { diff --git a/src/Command/ActivateUserCommand.php b/src/Command/ActivateUserCommand.php index 0d4601080..70b495ba0 100644 --- a/src/Command/ActivateUserCommand.php +++ b/src/Command/ActivateUserCommand.php @@ -53,14 +53,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int $user = $this->userManager->findUserByUsername($username); if (null === $user) { - throw new \InvalidArgumentException(sprintf('User identified by "%s" username does not exist.', $username)); + throw new \InvalidArgumentException(\sprintf('User identified by "%s" username does not exist.', $username)); } $user->setEnabled(true); $this->userManager->save($user); - $output->writeln(sprintf('User "%s" has been activated.', $username)); + $output->writeln(\sprintf('User "%s" has been activated.', $username)); return 0; } diff --git a/src/Command/ChangePasswordCommand.php b/src/Command/ChangePasswordCommand.php index 435bbf35f..aad9484a0 100644 --- a/src/Command/ChangePasswordCommand.php +++ b/src/Command/ChangePasswordCommand.php @@ -56,7 +56,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $user = $this->userManager->findUserByUsername($username); if (null === $user) { - throw new \InvalidArgumentException(sprintf('User identified by "%s" username does not exist.', $username)); + throw new \InvalidArgumentException(\sprintf('User identified by "%s" username does not exist.', $username)); } $user->setPlainPassword($password); @@ -64,7 +64,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->userManager->updatePassword($user); $this->userManager->save($user); - $output->writeln(sprintf('Changed password for user "%s".', $username)); + $output->writeln(\sprintf('Changed password for user "%s".', $username)); return 0; } diff --git a/src/Command/CreateUserCommand.php b/src/Command/CreateUserCommand.php index 256932661..9d88938d7 100644 --- a/src/Command/CreateUserCommand.php +++ b/src/Command/CreateUserCommand.php @@ -77,7 +77,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->userManager->save($user); - $output->writeln(sprintf('Created user "%s".', $username)); + $output->writeln(\sprintf('Created user "%s".', $username)); return 0; } diff --git a/src/Command/DeactivateUserCommand.php b/src/Command/DeactivateUserCommand.php index 253b63e9b..9a936e743 100644 --- a/src/Command/DeactivateUserCommand.php +++ b/src/Command/DeactivateUserCommand.php @@ -53,14 +53,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int $user = $this->userManager->findUserByUsername($username); if (null === $user) { - throw new \InvalidArgumentException(sprintf('User identified by "%s" username does not exist.', $username)); + throw new \InvalidArgumentException(\sprintf('User identified by "%s" username does not exist.', $username)); } $user->setEnabled(false); $this->userManager->save($user); - $output->writeln(sprintf('User "%s" has been activated.', $username)); + $output->writeln(\sprintf('User "%s" has been activated.', $username)); return 0; } diff --git a/src/Command/DemoteUserCommand.php b/src/Command/DemoteUserCommand.php index 88503d6be..bdd088b5d 100644 --- a/src/Command/DemoteUserCommand.php +++ b/src/Command/DemoteUserCommand.php @@ -67,19 +67,19 @@ protected function execute(InputInterface $input, OutputInterface $output): int $user = $this->userManager->findUserByUsername($username); if (null === $user) { - throw new \InvalidArgumentException(sprintf('User identified by "%s" username does not exist.', $username)); + throw new \InvalidArgumentException(\sprintf('User identified by "%s" username does not exist.', $username)); } if ($superAdmin) { $user->setSuperAdmin(false); - $output->writeln(sprintf('User "%s" has been demoted as a simple user. This change will not apply until the user logs out and back in again.', $username)); + $output->writeln(\sprintf('User "%s" has been demoted as a simple user. This change will not apply until the user logs out and back in again.', $username)); } elseif ($user->hasRole($role)) { $user->removeRole($role); - $output->writeln(sprintf('Role "%s" has been removed from user "%s". This change will not apply until the user logs out and back in again.', $role, $username)); + $output->writeln(\sprintf('Role "%s" has been removed from user "%s". This change will not apply until the user logs out and back in again.', $role, $username)); } else { - $output->writeln(sprintf('User "%s" didn\'t have "%s" role.', $username, $role)); + $output->writeln(\sprintf('User "%s" didn\'t have "%s" role.', $username, $role)); } $this->userManager->save($user); diff --git a/src/Command/PromoteUserCommand.php b/src/Command/PromoteUserCommand.php index 0a16fa246..d262262bc 100644 --- a/src/Command/PromoteUserCommand.php +++ b/src/Command/PromoteUserCommand.php @@ -67,19 +67,19 @@ protected function execute(InputInterface $input, OutputInterface $output): int $user = $this->userManager->findUserByUsername($username); if (null === $user) { - throw new \InvalidArgumentException(sprintf('User identified by "%s" username does not exist.', $username)); + throw new \InvalidArgumentException(\sprintf('User identified by "%s" username does not exist.', $username)); } if ($superAdmin) { $user->setSuperAdmin(true); - $output->writeln(sprintf('User "%s" has been promoted as a super administrator. This change will not apply until the user logs out and back in again.', $username)); + $output->writeln(\sprintf('User "%s" has been promoted as a super administrator. This change will not apply until the user logs out and back in again.', $username)); } elseif (!$user->hasRole($role)) { $user->addRole($role); - $output->writeln(sprintf('Role "%s" has been added to user "%s". This change will not apply until the user logs out and back in again.', $role, $username)); + $output->writeln(\sprintf('Role "%s" has been added to user "%s". This change will not apply until the user logs out and back in again.', $role, $username)); } else { - $output->writeln(sprintf('User "%s" did already have "%s" role.', $username, $role)); + $output->writeln(\sprintf('User "%s" did already have "%s" role.', $username, $role)); } $this->userManager->save($user); diff --git a/src/DependencyInjection/SonataUserExtension.php b/src/DependencyInjection/SonataUserExtension.php index 525ead004..942a86515 100644 --- a/src/DependencyInjection/SonataUserExtension.php +++ b/src/DependencyInjection/SonataUserExtension.php @@ -48,11 +48,11 @@ public function load(array $configs, ContainerBuilder $container): void if (isset($bundles['SonataAdminBundle'])) { $loader->load('admin.php'); - $loader->load(sprintf('admin_%s.php', $config['manager_type'])); + $loader->load(\sprintf('admin_%s.php', $config['manager_type'])); $loader->load('actions.php'); } - $loader->load(sprintf('%s.php', $config['manager_type'])); + $loader->load(\sprintf('%s.php', $config['manager_type'])); $container->setParameter('sonata.user.manager_type', $config['manager_type']); $loader->load('twig.php'); @@ -139,7 +139,7 @@ private function checkManagerTypeToModelTypesMapping(array $config): void $managerType = $config['manager_type']; if (!\in_array($managerType, ['orm', 'mongodb'], true)) { - throw new \InvalidArgumentException(sprintf('Invalid manager type "%s".', $managerType)); + throw new \InvalidArgumentException(\sprintf('Invalid manager type "%s".', $managerType)); } $this->prohibitModelTypeMapping( @@ -162,7 +162,7 @@ private function prohibitModelTypeMapping( ): void { if (is_a($actualModelClass, $prohibitedModelClass, true)) { throw new \InvalidArgumentException( - sprintf( + \sprintf( 'Model class "%s" does not correspond to manager type "%s".', $actualModelClass, $managerType diff --git a/src/Mailer/Mailer.php b/src/Mailer/Mailer.php index 7f6d4c7e1..8268e2947 100644 --- a/src/Mailer/Mailer.php +++ b/src/Mailer/Mailer.php @@ -55,7 +55,7 @@ public function sendResettingEmailMessage(UserInterface $user): void $this->mailer->send( (new Email()) - ->from(sprintf('%s <%s>', $fromName, $fromAddress)) + ->from(\sprintf('%s <%s>', $fromName, $fromAddress)) ->to((string) $user->getEmail()) ->subject($subject) ->html($body) diff --git a/src/Security/RolesBuilder/AdminRolesBuilder.php b/src/Security/RolesBuilder/AdminRolesBuilder.php index f286e79a9..d90a92d91 100644 --- a/src/Security/RolesBuilder/AdminRolesBuilder.php +++ b/src/Security/RolesBuilder/AdminRolesBuilder.php @@ -110,7 +110,7 @@ private function getAdminRolesByAdminCode(string $code, ?string $domain = null, $adminLabelTranslated = $admin->getTranslator()->trans($admin->getLabel() ?? '', [], $admin->getTranslationDomain()); $isMasterAdmin = $this->isMaster($admin); foreach (array_keys($admin->getSecurityInformation()) as $key) { - $role = sprintf($baseRole, $key); + $role = \sprintf($baseRole, $key); $adminRoles[$role] = [ 'role' => $role, 'label' => $key, diff --git a/src/Security/UserProvider.php b/src/Security/UserProvider.php index 1c42e2760..9390c4ed4 100644 --- a/src/Security/UserProvider.php +++ b/src/Security/UserProvider.php @@ -42,7 +42,7 @@ public function loadUserByIdentifier(string $identifier): SecurityUserInterface $user = $this->findUser($identifier); if (null === $user || !$user->isEnabled()) { - throw new UserNotFoundException(sprintf('Username "%s" does not exist.', $identifier)); + throw new UserNotFoundException(\sprintf('Username "%s" does not exist.', $identifier)); } return $user; @@ -51,15 +51,15 @@ public function loadUserByIdentifier(string $identifier): SecurityUserInterface public function refreshUser(SecurityUserInterface $user): SecurityUserInterface { if (!$user instanceof UserInterface) { - throw new UnsupportedUserException(sprintf('Expected an instance of %s, but got "%s".', UserInterface::class, $user::class)); + throw new UnsupportedUserException(\sprintf('Expected an instance of %s, but got "%s".', UserInterface::class, $user::class)); } if (!$this->supportsClass($user::class)) { - throw new UnsupportedUserException(sprintf('Expected an instance of %s, but got "%s".', $this->userManager->getClass(), $user::class)); + throw new UnsupportedUserException(\sprintf('Expected an instance of %s, but got "%s".', $this->userManager->getClass(), $user::class)); } if (null === $reloadedUser = $this->userManager->findOneBy(['id' => $user->getId()])) { - throw new UserNotFoundException(sprintf('User with ID "%s" could not be reloaded.', $user->getId() ?? '')); + throw new UserNotFoundException(\sprintf('User with ID "%s" could not be reloaded.', $user->getId() ?? '')); } return $reloadedUser; diff --git a/tests/Functional/Action/ResetActionTest.php b/tests/Functional/Action/ResetActionTest.php index 2229dcfd3..f3a556d48 100644 --- a/tests/Functional/Action/ResetActionTest.php +++ b/tests/Functional/Action/ResetActionTest.php @@ -39,7 +39,7 @@ public function testItSubmitsResetPasswordFormWithNonValidData(): void static::assertSame($user->getPassword(), 'random_password'); - $client->request('GET', sprintf('/reset/%s', $confirmationToken)); + $client->request('GET', \sprintf('/reset/%s', $confirmationToken)); static::assertResponseIsSuccessful(); @@ -62,7 +62,7 @@ public function testItResetsPassword(): void static::assertSame($user->getPassword(), 'random_password'); - $client->request('GET', sprintf('/reset/%s', $confirmationToken)); + $client->request('GET', \sprintf('/reset/%s', $confirmationToken)); $client->submitForm('submit', [ 'resetting_form[plainPassword][first]' => 'new_password', diff --git a/tests/Mailer/MailerTest.php b/tests/Mailer/MailerTest.php index a8caa5f40..bd26849e9 100644 --- a/tests/Mailer/MailerTest.php +++ b/tests/Mailer/MailerTest.php @@ -94,7 +94,7 @@ public function testSendResettingEmailMessage(string $template, string $subject, $fromAddress = current(array_keys($this->emailFrom)); $email = (new Email()) - ->from(sprintf('%s <%s>', $fromName, $fromAddress)) + ->from(\sprintf('%s <%s>', $fromName, $fromAddress)) ->to((string) $user->getEmail()) ->subject($subject) ->html($body);