Skip to content

Commit

Permalink
Merge branch '5.4' into 6.3
Browse files Browse the repository at this point in the history
* 5.4:
  Fix implicitly-required parameters
  List CS fix in .git-blame-ignore-revs
  Apply php-cs-fixer fix --rules nullable_type_declaration_for_default_null_value
  [Messenger][AmazonSqs] Allow async-aws/sqs version 2
  • Loading branch information
nicolas-grekas committed Jan 23, 2024
2 parents 82161c4 + 23b9782 commit 5131409
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Exception/InvalidPasswordException.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
class InvalidPasswordException extends \RuntimeException implements ExceptionInterface
{
public function __construct(string $message = 'Invalid password.', int $code = 0, \Throwable $previous = null)
public function __construct(string $message = 'Invalid password.', int $code = 0, ?\Throwable $previous = null)
{
parent::__construct($message, $code, $previous);
}
Expand Down
4 changes: 2 additions & 2 deletions Hasher/MessageDigestPasswordHasher.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function __construct(string $algorithm = 'sha512', bool $encodeHashAsBase
$this->iterations = $iterations;
}

public function hash(#[\SensitiveParameter] string $plainPassword, string $salt = null): string
public function hash(#[\SensitiveParameter] string $plainPassword, ?string $salt = null): string
{
if ($this->isPasswordTooLong($plainPassword)) {
throw new InvalidPasswordException();
Expand All @@ -69,7 +69,7 @@ public function hash(#[\SensitiveParameter] string $plainPassword, string $salt
return $this->encodeHashAsBase64 ? base64_encode($digest) : bin2hex($digest);
}

public function verify(string $hashedPassword, #[\SensitiveParameter] string $plainPassword, string $salt = null): bool
public function verify(string $hashedPassword, #[\SensitiveParameter] string $plainPassword, ?string $salt = null): bool
{
if (\strlen($hashedPassword) !== $this->hashLength || str_contains($hashedPassword, '$')) {
return false;
Expand Down
4 changes: 2 additions & 2 deletions Hasher/MigratingPasswordHasher.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ public function __construct(PasswordHasherInterface $bestHasher, PasswordHasherI
$this->extraHashers = $extraHashers;
}

public function hash(#[\SensitiveParameter] string $plainPassword, string $salt = null): string
public function hash(#[\SensitiveParameter] string $plainPassword, ?string $salt = null): string
{
return $this->bestHasher->hash($plainPassword, $salt);
}

public function verify(string $hashedPassword, #[\SensitiveParameter] string $plainPassword, string $salt = null): bool
public function verify(string $hashedPassword, #[\SensitiveParameter] string $plainPassword, ?string $salt = null): bool
{
if ($this->bestHasher->verify($hashedPassword, $plainPassword, $salt)) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion Hasher/NativePasswordHasher.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ final class NativePasswordHasher implements PasswordHasherInterface
/**
* @param string|null $algorithm An algorithm supported by password_hash() or null to use the best available algorithm
*/
public function __construct(int $opsLimit = null, int $memLimit = null, int $cost = null, string $algorithm = null)
public function __construct(?int $opsLimit = null, ?int $memLimit = null, ?int $cost = null, ?string $algorithm = null)
{
$cost ??= 13;
$opsLimit ??= max(4, \defined('SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE') ? \SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE : 4);
Expand Down
4 changes: 2 additions & 2 deletions Hasher/Pbkdf2PasswordHasher.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function __construct(string $algorithm = 'sha512', bool $encodeHashAsBase
$this->iterations = $iterations;
}

public function hash(#[\SensitiveParameter] string $plainPassword, string $salt = null): string
public function hash(#[\SensitiveParameter] string $plainPassword, ?string $salt = null): string
{
if ($this->isPasswordTooLong($plainPassword)) {
throw new InvalidPasswordException();
Expand All @@ -74,7 +74,7 @@ public function hash(#[\SensitiveParameter] string $plainPassword, string $salt
return $this->encodeHashAsBase64 ? base64_encode($digest) : bin2hex($digest);
}

public function verify(string $hashedPassword, #[\SensitiveParameter] string $plainPassword, string $salt = null): bool
public function verify(string $hashedPassword, #[\SensitiveParameter] string $plainPassword, ?string $salt = null): bool
{
if (\strlen($hashedPassword) !== $this->encodedLength || str_contains($hashedPassword, '$')) {
return false;
Expand Down
4 changes: 2 additions & 2 deletions Hasher/PlaintextPasswordHasher.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct(bool $ignorePasswordCase = false)
$this->ignorePasswordCase = $ignorePasswordCase;
}

public function hash(#[\SensitiveParameter] string $plainPassword, string $salt = null): string
public function hash(#[\SensitiveParameter] string $plainPassword, ?string $salt = null): string
{
if ($this->isPasswordTooLong($plainPassword)) {
throw new InvalidPasswordException();
Expand All @@ -44,7 +44,7 @@ public function hash(#[\SensitiveParameter] string $plainPassword, string $salt
return $this->mergePasswordAndSalt($plainPassword, $salt);
}

public function verify(string $hashedPassword, #[\SensitiveParameter] string $plainPassword, string $salt = null): bool
public function verify(string $hashedPassword, #[\SensitiveParameter] string $plainPassword, ?string $salt = null): bool
{
if ($this->isPasswordTooLong($plainPassword)) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion Hasher/SodiumPasswordHasher.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class SodiumPasswordHasher implements PasswordHasherInterface
private int $opsLimit;
private int $memLimit;

public function __construct(int $opsLimit = null, int $memLimit = null)
public function __construct(?int $opsLimit = null, ?int $memLimit = null)
{
if (!self::isSupported()) {
throw new LogicException('Libsodium is not available. You should either install the sodium extension or use a different password hasher.');
Expand Down
4 changes: 2 additions & 2 deletions LegacyPasswordHasherInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ interface LegacyPasswordHasherInterface extends PasswordHasherInterface
*
* @throws InvalidPasswordException If the plain password is invalid, e.g. excessively long
*/
public function hash(#[\SensitiveParameter] string $plainPassword, string $salt = null): string;
public function hash(#[\SensitiveParameter] string $plainPassword, ?string $salt = null): string;

/**
* Checks that a plain password and a salt match a password hash.
*/
public function verify(string $hashedPassword, #[\SensitiveParameter] string $plainPassword, string $salt = null): bool;
public function verify(string $hashedPassword, #[\SensitiveParameter] string $plainPassword, ?string $salt = null): bool;
}

0 comments on commit 5131409

Please sign in to comment.