Skip to content

Commit

Permalink
Fix CS
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Feb 9, 2025
1 parent 7bb93e7 commit 94a05bf
Show file tree
Hide file tree
Showing 32 changed files with 58 additions and 58 deletions.
2 changes: 1 addition & 1 deletion src/Command/ActivateUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$this->userManipulator->activate($username);

$output->writeln(sprintf('User "%s" has been activated.', $username));
$output->writeln(\sprintf('User "%s" has been activated.', $username));

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Command/ChangePasswordCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$this->userManipulator->changePassword($username, $password);

$output->writeln(sprintf('Changed password for user <comment>%s</comment>', $username));
$output->writeln(\sprintf('Changed password for user <comment>%s</comment>', $username));

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Command/CreateUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$this->userManipulator->create($username, $password, $email, !$inactive, $superadmin);

$output->writeln(sprintf('Created user <comment>%s</comment>', $username));
$output->writeln(\sprintf('Created user <comment>%s</comment>', $username));

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Command/DeactivateUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$this->userManipulator->deactivate($username);

$output->writeln(sprintf('User "%s" has been deactivated.', $username));
$output->writeln(\sprintf('User "%s" has been deactivated.', $username));

return 0;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Command/DemoteUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ protected function executeRoleCommand(UserManipulator $manipulator, OutputInterf
{
if ($super) {
$manipulator->demote($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));
$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 ($manipulator->removeRole($username, $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));
}
}
}
6 changes: 3 additions & 3 deletions src/Command/PromoteUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ protected function executeRoleCommand(UserManipulator $manipulator, OutputInterf
{
if ($super) {
$manipulator->promote($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));
$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 ($manipulator->addRole($username, $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));
}
}
}
8 changes: 4 additions & 4 deletions src/DependencyInjection/NucleosUserExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function load(array $configs, ContainerBuilder $container): void
$loader->load('doctrine.php');
$container->setAlias('nucleos_user.doctrine_registry', new Alias(self::$doctrineDrivers[$config['db_driver']]['registry'], false));
} else {
$loader->load(sprintf('%s.php', $config['db_driver']));
$loader->load(\sprintf('%s.php', $config['db_driver']));
}
$container->setParameter($this->getAlias().'.backend_type_'.$config['db_driver'], true);
}
Expand All @@ -84,7 +84,7 @@ public function load(array $configs, ContainerBuilder $container): void
}

foreach (['validator', 'security', 'util', 'mailer', 'listeners', 'commands'] as $basename) {
$loader->load(sprintf('%s.php', $basename));
$loader->load(\sprintf('%s.php', $basename));
}

if (!$config['use_authentication_listener']) {
Expand Down Expand Up @@ -186,7 +186,7 @@ private function remapParametersNamespaces(array $config, ContainerBuilder $cont
$this->remapParameters($namespaceConfig, $container, $map);
} else {
foreach ($namespaceConfig as $name => $value) {
$container->setParameter(sprintf($map, $name), $value);
$container->setParameter(\sprintf($map, $name), $value);
}
}
}
Expand Down Expand Up @@ -234,7 +234,7 @@ private function loadGroups(array $config, ContainerBuilder $container, FileLoad
if (isset(self::$doctrineDrivers[$dbDriver])) {
$loader->load('doctrine_group.php');
} else {
$loader->load(sprintf('%s_group.php', $dbDriver));
$loader->load(\sprintf('%s_group.php', $dbDriver));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Event/GetResponseLoginEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class GetResponseLoginEvent extends Event

private ?Response $response = null;

public function __construct(Request $request = null)
public function __construct(?Request $request = null)
{
$this->request = $request;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Event/UserEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class UserEvent extends Event

protected readonly UserInterface $user;

public function __construct(UserInterface $user, Request $request = null)
public function __construct(UserInterface $user, ?Request $request = null)
{
$this->user = $user;
$this->request = $request;
Expand Down
4 changes: 2 additions & 2 deletions src/Model/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public function setPlainPassword(?string $password): void
$this->passwordRequestedAt = null;
}

public function setLastLogin(DateTime $time = null): void
public function setLastLogin(?DateTime $time = null): void
{
$this->lastLogin = $time;
}
Expand All @@ -218,7 +218,7 @@ public function setConfirmationToken(?string $confirmationToken): void
$this->confirmationToken = $confirmationToken;
}

public function setPasswordRequestedAt(DateTime $date = null): void
public function setPasswordRequestedAt(?DateTime $date = null): void
{
$this->passwordRequestedAt = $date;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Model/UserInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function setConfirmationToken(?string $confirmationToken): void;
/**
* Sets the timestamp that the user requested a password reset.
*/
public function setPasswordRequestedAt(DateTime $date = null): void;
public function setPasswordRequestedAt(?DateTime $date = null): void;

/**
* Checks whether the password reset request has expired.
Expand All @@ -103,7 +103,7 @@ public function isPasswordRequestNonExpired(int $ttl): bool;
/**
* Sets the last login time.
*/
public function setLastLogin(DateTime $time = null): void;
public function setLastLogin(?DateTime $time = null): void;

/**
* Never use this to check if this user has access to anything!
Expand Down
2 changes: 1 addition & 1 deletion src/Noop/Exception/NoDriverException.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

final class NoDriverException extends RuntimeException
{
public function __construct(?string $message = null, int $code = 0, Exception $previous = null)
public function __construct(?string $message = null, int $code = 0, ?Exception $previous = null)
{
parent::__construct(
null === $message ? 'The child node "db_driver" at path "nucleos_user" must be configured.' : $message,
Expand Down
2 changes: 1 addition & 1 deletion src/Security/LoginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@

interface LoginManager
{
public function logInUser(string $firewallName, UserInterface $user, Response $response = null): void;
public function logInUser(string $firewallName, UserInterface $user, ?Response $response = null): void;
}
2 changes: 1 addition & 1 deletion src/Security/SimpleLoginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct(
$this->requestStack = $requestStack;
}

public function logInUser(string $firewallName, UserInterface $user, Response $response = null): void
public function logInUser(string $firewallName, UserInterface $user, ?Response $response = null): void
{
$this->userChecker->checkPreAuth($user);

Expand Down
8 changes: 4 additions & 4 deletions src/Security/UserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function loadUserByUsername(string $username): UserInterface
$user = $this->findUser($username);

if (null === $user) {
throw new UserNotFoundException(sprintf('Username "%s" does not exist.', $username));
throw new UserNotFoundException(\sprintf('Username "%s" does not exist.', $username));
}

return $user;
Expand All @@ -52,15 +52,15 @@ public function loadUserByUsername(string $username): UserInterface
public function refreshUser(SecurityUserInterface $user): UserInterface
{
if (!$user instanceof UserInterface) {
throw new UnsupportedUserException(sprintf('Expected an instance of Nucleos\UserBundle\Model\UserInterface, but got "%s".', \get_class($user)));
throw new UnsupportedUserException(\sprintf('Expected an instance of Nucleos\UserBundle\Model\UserInterface, but got "%s".', \get_class($user)));
}

if (!$this->supportsClass(\get_class($user))) {
throw new UnsupportedUserException(sprintf('Expected an instance of %s, but got "%s".', $this->userManager->getClass(), \get_class($user)));
throw new UnsupportedUserException(\sprintf('Expected an instance of %s, but got "%s".', $this->userManager->getClass(), \get_class($user)));
}

if (null === $reloadedUser = $this->findUser($user->getUserIdentifier())) {
throw new AuthenticationException(sprintf('User with ID "%s" could not be reloaded.', $user->getUserIdentifier()));
throw new AuthenticationException(\sprintf('User with ID "%s" could not be reloaded.', $user->getUserIdentifier()));
}

return $reloadedUser;
Expand Down
2 changes: 1 addition & 1 deletion src/Util/SimpleUserManipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ private function findUserByUsernameOrThrowException(string $username): UserInter
$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));
}

return $user;
Expand Down
22 changes: 11 additions & 11 deletions src/Validator/Constraints/Pattern.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,23 @@ final class Pattern extends Constraint

public int $minSpecial = 0;

public string $specialChars = '.,:;!?:+-*#\\/|(){}[]';
public string $specialChars = '.,:;!?:+-*#\/|(){}[]';

/**
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
mixed $options = null,
int $minUpper = null,
int $minLower = null,
int $minNumeric = null,
int $minSpecial = null,
string $specialChars = null,
string $minUpperMessage = null,
string $minLowerMessage = null,
string $minNumericMessage = null,
string $minSpecialMessage = null,
array $groups = null,
?int $minUpper = null,
?int $minLower = null,
?int $minNumeric = null,
?int $minSpecial = null,
?string $specialChars = null,
?string $minUpperMessage = null,
?string $minLowerMessage = null,
?string $minNumericMessage = null,
?string $minSpecialMessage = null,
?array $groups = null,
mixed $payload = null
) {
parent::__construct($options, $groups, $payload);
Expand Down
2 changes: 1 addition & 1 deletion src/Validator/Constraints/PatternValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private function validateNumeric(Pattern $constraint, string $value): void
if ($constraint->minNumeric <= 0) {
return;
}
if ($this->countMatches('/[\\d]/', $value) < $constraint->minNumeric) {
if ($this->countMatches('/[\d]/', $value) < $constraint->minNumeric) {
$this->context
->buildViolation($constraint->minNumericMessage, [
'{{ count }}' => $constraint->minNumeric,
Expand Down
2 changes: 1 addition & 1 deletion tests/Command/ActivateUserCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function testExecuteInteractiveWithQuestionHelper(): void
self::assertMatchesRegularExpression('/User "user" has been activated/', $commandTester->getDisplay());
}

private function createCommandTester(UserManipulator $manipulator, Application $application = null): CommandTester
private function createCommandTester(UserManipulator $manipulator, ?Application $application = null): CommandTester
{
if (null === $application) {
$application = new Application();
Expand Down
2 changes: 1 addition & 1 deletion tests/Command/ChangePasswordCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function testExecuteInteractiveWithQuestionHelper(): void
self::assertMatchesRegularExpression('/Changed password for user user/', $commandTester->getDisplay());
}

private function createCommandTester(UserManipulator $manipulator, Application $application = null): CommandTester
private function createCommandTester(UserManipulator $manipulator, ?Application $application = null): CommandTester
{
if (null === $application) {
$application = new Application();
Expand Down
2 changes: 1 addition & 1 deletion tests/Command/CreateUserCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function testExecuteInteractiveWithQuestionHelper(): void
self::assertMatchesRegularExpression('/Created user user/', $commandTester->getDisplay());
}

private function createCommandTester(UserManipulator $manipulator, Application $application = null): CommandTester
private function createCommandTester(UserManipulator $manipulator, ?Application $application = null): CommandTester
{
if (null === $application) {
$application = new Application();
Expand Down
2 changes: 1 addition & 1 deletion tests/Command/DeactivateUserCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function testExecuteInteractiveWithQuestionHelper(): void
self::assertMatchesRegularExpression('/User "user" has been deactivated/', $commandTester->getDisplay());
}

private function createCommandTester(UserManipulator $manipulator, Application $application = null): CommandTester
private function createCommandTester(UserManipulator $manipulator, ?Application $application = null): CommandTester
{
if (null === $application) {
$application = new Application();
Expand Down
2 changes: 1 addition & 1 deletion tests/Command/DemoteUserCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function testExecuteInteractiveWithQuestionHelper(): void
self::assertMatchesRegularExpression('/Role "role" has been removed from user "user"/', $commandTester->getDisplay());
}

private function createCommandTester(UserManipulator $manipulator, Application $application = null): CommandTester
private function createCommandTester(UserManipulator $manipulator, ?Application $application = null): CommandTester
{
if (null === $application) {
$application = new Application();
Expand Down
2 changes: 1 addition & 1 deletion tests/Command/PromoteUserCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function testExecuteInteractiveWithQuestionHelper(): void
self::assertMatchesRegularExpression('/Role "role" has been added to user "user"/', $commandTester->getDisplay());
}

private function createCommandTester(UserManipulator $manipulator, Application $application = null): CommandTester
private function createCommandTester(UserManipulator $manipulator, ?Application $application = null): CommandTester
{
if (null === $application) {
$application = new Application();
Expand Down
4 changes: 2 additions & 2 deletions tests/DependencyInjection/NucleosUserExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,15 +271,15 @@ protected function getFullConfig(): array

private function assertAlias(string $value, string $key): void
{
self::assertSame($value, (string) $this->configuration->getAlias($key), sprintf('%s alias is correct', $key));
self::assertSame($value, (string) $this->configuration->getAlias($key), \sprintf('%s alias is correct', $key));
}

/**
* @param mixed $value
*/
private function assertParameter($value, string $key): void
{
self::assertSame($value, $this->configuration->getParameter($key), sprintf('%s parameter is correct', $key));
self::assertSame($value, $this->configuration->getParameter($key), \sprintf('%s parameter is correct', $key));
}

private function assertHasDefinition(string $id): void
Expand Down
2 changes: 1 addition & 1 deletion tests/Form/Type/ResettingFormTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class ResettingFormTypeTest extends ValidatorExtensionTypeTestCase
{
public function testSubmit(): void
{
$model = new Resetting($this->createStub(UserInterface::class));
$model = new Resetting(self::createStub(UserInterface::class));

$form = $this->factory->create(ResettingFormType::class, $model);
$formData = [
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/Action/RequestPasswordWebTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private function performConfirmation(KernelBrowser $client, TestUser $user): voi
{
$oldPassword = $user->getPassword();

$client->request('GET', sprintf('/resetting/reset/%s', $user->getConfirmationToken()));
$client->request('GET', \sprintf('/resetting/reset/%s', $user->getConfirmationToken()));

self::assertResponseIsSuccessful();

Expand Down
4 changes: 2 additions & 2 deletions tests/Functional/DoctrineSetupTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ trait DoctrineSetupTrait
* @param string[] $roles
*/
public static function createUser(
string $username = null,
?string $username = null,
array $roles = []
): TestUser {
$entity = new TestUser();
Expand All @@ -32,7 +32,7 @@ public static function createUser(
$username ??= ('my-user'.$entity->getId());

$entity->setUsername($username);
$entity->setEmail(sprintf('%s@localhost', $username));
$entity->setEmail(\sprintf('%s@localhost', $username));
$entity->setRoles($roles);

return $entity;
Expand Down
6 changes: 3 additions & 3 deletions tests/Resources/XliffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function testXliff(string $locale): void
$this->validateXliff($locale);

if (\count($this->errors) > 0) {
self::fail(sprintf('Unable to parse xliff files: %s', implode(', ', $this->errors)));
self::fail(\sprintf('Unable to parse xliff files: %s', implode(', ', $this->errors)));
}
}

Expand All @@ -49,7 +49,7 @@ public function testXliff(string $locale): void
*/
public static function provideXliffCases(): iterable
{
$files = glob(sprintf('%s/*.xlf', __DIR__.'/../../src/Resources/translations'));
$files = glob(\sprintf('%s/*.xlf', __DIR__.'/../../src/Resources/translations'));

if (false === $files) {
return;
Expand All @@ -69,7 +69,7 @@ private function validateXliff(string $file): void

self::assertGreaterThan(0, $catalogue->getResources());
} catch (InvalidResourceException $e) {
$this->errors[] = sprintf('%s => %s', $locale, $e->getMessage());
$this->errors[] = \sprintf('%s => %s', $locale, $e->getMessage());
}
}
}
Loading

0 comments on commit 94a05bf

Please sign in to comment.