From dcab5ac87450aaed26483ba49c2ce86808da7557 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 10 Jul 2025 09:12:18 +0200 Subject: [PATCH] CS fixes --- Command/UserPasswordHashCommand.php | 2 +- Hasher/MessageDigestPasswordHasher.php | 2 +- Hasher/PasswordHasherFactory.php | 8 ++++---- Hasher/Pbkdf2PasswordHasher.php | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Command/UserPasswordHashCommand.php b/Command/UserPasswordHashCommand.php index f94d07f..be2a802 100644 --- a/Command/UserPasswordHashCommand.php +++ b/Command/UserPasswordHashCommand.php @@ -152,7 +152,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $io->table(['Key', 'Value'], $rows); if (!$emptySalt) { - $errorIo->note(sprintf('Make sure that your salt storage field fits the salt length: %s chars', \strlen($salt))); + $errorIo->note(\sprintf('Make sure that your salt storage field fits the salt length: %s chars', \strlen($salt))); } elseif ($saltlessWithoutEmptySalt) { $errorIo->note('Self-salting hasher used: the hasher generated its own built-in salt.'); } diff --git a/Hasher/MessageDigestPasswordHasher.php b/Hasher/MessageDigestPasswordHasher.php index 0e7d738..d6dccf4 100644 --- a/Hasher/MessageDigestPasswordHasher.php +++ b/Hasher/MessageDigestPasswordHasher.php @@ -55,7 +55,7 @@ public function hash(#[\SensitiveParameter] string $plainPassword, ?string $salt } if (!\in_array($this->algorithm, hash_algos(), true)) { - throw new LogicException(sprintf('The algorithm "%s" is not supported.', $this->algorithm)); + throw new LogicException(\sprintf('The algorithm "%s" is not supported.', $this->algorithm)); } $salted = $this->mergePasswordAndSalt($plainPassword, $salt); diff --git a/Hasher/PasswordHasherFactory.php b/Hasher/PasswordHasherFactory.php index 7c03917..dca8267 100644 --- a/Hasher/PasswordHasherFactory.php +++ b/Hasher/PasswordHasherFactory.php @@ -39,7 +39,7 @@ public function getPasswordHasher(string|PasswordAuthenticatedUserInterface|Pass if ($user instanceof PasswordHasherAwareInterface && null !== $hasherName = $user->getPasswordHasherName()) { if (!\array_key_exists($hasherName, $this->passwordHashers)) { - throw new \RuntimeException(sprintf('The password hasher "%s" was not configured.', $hasherName)); + throw new \RuntimeException(\sprintf('The password hasher "%s" was not configured.', $hasherName)); } $hasherKey = $hasherName; @@ -53,7 +53,7 @@ public function getPasswordHasher(string|PasswordAuthenticatedUserInterface|Pass } if (null === $hasherKey) { - throw new \RuntimeException(sprintf('No password hasher has been configured for account "%s".', \is_object($user) ? get_debug_type($user) : $user)); + throw new \RuntimeException(\sprintf('No password hasher has been configured for account "%s".', \is_object($user) ? get_debug_type($user) : $user)); } if (!$this->passwordHashers[$hasherKey] instanceof PasswordHasherInterface) { @@ -188,7 +188,7 @@ private function getHasherConfigFromAlgorithm(array $config): array $config['algorithm'] = 'native'; $config['native_algorithm'] = \PASSWORD_ARGON2I; } else { - throw new LogicException(sprintf('Algorithm "argon2i" is not available. Use "%s" instead.', \defined('SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13') ? 'argon2id" or "auto' : 'auto')); + throw new LogicException(\sprintf('Algorithm "argon2i" is not available. Use "%s" instead.', \defined('SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13') ? 'argon2id" or "auto' : 'auto')); } return $this->getHasherConfigFromAlgorithm($config); @@ -200,7 +200,7 @@ private function getHasherConfigFromAlgorithm(array $config): array $config['algorithm'] = 'native'; $config['native_algorithm'] = \PASSWORD_ARGON2ID; } else { - throw new LogicException(sprintf('Algorithm "argon2id" is not available. Either use "%s", upgrade to PHP 7.3+ or use libsodium 1.0.15+ instead.', \defined('PASSWORD_ARGON2I') || $hasSodium ? 'argon2i", "auto' : 'auto')); + throw new LogicException(\sprintf('Algorithm "argon2id" is not available. Either use "%s", upgrade to PHP 7.3+ or use libsodium 1.0.15+ instead.', \defined('PASSWORD_ARGON2I') || $hasSodium ? 'argon2i", "auto' : 'auto')); } return $this->getHasherConfigFromAlgorithm($config); diff --git a/Hasher/Pbkdf2PasswordHasher.php b/Hasher/Pbkdf2PasswordHasher.php index 45d390c..fd61882 100644 --- a/Hasher/Pbkdf2PasswordHasher.php +++ b/Hasher/Pbkdf2PasswordHasher.php @@ -66,7 +66,7 @@ public function hash(#[\SensitiveParameter] string $plainPassword, ?string $salt } if (!\in_array($this->algorithm, hash_algos(), true)) { - throw new LogicException(sprintf('The algorithm "%s" is not supported.', $this->algorithm)); + throw new LogicException(\sprintf('The algorithm "%s" is not supported.', $this->algorithm)); } $digest = hash_pbkdf2($this->algorithm, $plainPassword, $salt ?? '', $this->iterations, $this->length, true);