The $algorithms array is only used when $algorithm is set

This commit is contained in:
Jan Rosier 2021-03-25 17:57:36 +01:00
parent 2dcf313a87
commit 0144d0a151

View File

@ -49,6 +49,7 @@ final class NativePasswordHasher implements PasswordHasherInterface
throw new \InvalidArgumentException('$cost must be in the range of 4-31.');
}
if (null !== $algorithm) {
$algorithms = [1 => \PASSWORD_BCRYPT, '2y' => \PASSWORD_BCRYPT];
if (\defined('PASSWORD_ARGON2I')) {
@ -59,7 +60,6 @@ final class NativePasswordHasher implements PasswordHasherInterface
$algorithms[3] = $algorithms['argon2id'] = (string) \PASSWORD_ARGON2ID;
}
if (null !== $algorithm) {
$this->algorithm = $algorithms[$algorithm] ?? $algorithm;
}