Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ infection.json export-ignore
Makefile export-ignore
phpstan.neon.dist export-ignore
phpstan-baseline.neon export-ignore
psalm-baseline.xml export-ignore
psalm.xml export-ignore
phpunit.xml.dist export-ignore
/docs export-ignore
/tests export-ignore
Expand Down
2 changes: 1 addition & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
'null_adjustment' => 'always_last',
],
'phpdoc_to_comment' => [
'ignored_tags' => ['psalm-suppress'],
'ignored_tags' => [],
],
'php_unit_internal_class' => false,
'php_unit_test_class_requires_covers' => false,
Expand Down
4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ cs: vendor-bin/tools/vendor
cs-fix: vendor-bin/tools/vendor
vendor/bin/php-cs-fixer fix --verbose

.PHONY: psalm
psalm: vendor-bin/tools/vendor
vendor/bin/psalm --config=psalm.xml --diff --shepherd --show-info=false --stats --threads=4

.PHONY: phpstan
phpstan: vendor-bin/tools/vendor
vendor/bin/phpstan analyse
Expand Down
59 changes: 0 additions & 59 deletions psalm-baseline.xml

This file was deleted.

15 changes: 0 additions & 15 deletions psalm.xml

This file was deleted.

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 @@ -93,7 +93,7 @@

public function getUserIdentifier(): string
{
return $this->getUsername();

Check failure on line 96 in src/Model/User.php

View workflow job for this annotation

GitHub Actions / run / Static Code Analysis (8.4)

Method Nucleos\UserBundle\Model\User::getUserIdentifier() should return non-empty-string but returns string.
}

public function getEmail(): string
Expand Down Expand Up @@ -208,7 +208,7 @@
$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 @@
$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
1 change: 0 additions & 1 deletion src/NucleosUserBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ private function addRegisterMappingsPass(ContainerBuilder $container): void
$container->addCompilerPass(DoctrineOrmMappingsPass::createXmlMappingDriver($mappings, ['nucleos_user.model_manager_name'], 'nucleos_user.backend_type_orm'));
}
if (class_exists(DoctrineMongoDBMappingsPass::class)) {
/** @psalm-suppress InternalClass, InternalMethod */
$container->addCompilerPass(DoctrineMongoDBMappingsPass::createXmlMappingDriver($mappings, ['nucleos_user.model_manager_name'], 'nucleos_user.backend_type_mongodb'));
}
}
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
Loading
Loading