Skip to content

Commit 23b9782

Browse files
Apply php-cs-fixer fix --rules nullable_type_declaration_for_default_null_value
1 parent f1a0718 commit 23b9782

8 files changed

+13
-13
lines changed

Exception/InvalidPasswordException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
class InvalidPasswordException extends \RuntimeException implements ExceptionInterface
1818
{
19-
public function __construct(string $message = 'Invalid password.', int $code = 0, \Throwable $previous = null)
19+
public function __construct(string $message = 'Invalid password.', int $code = 0, ?\Throwable $previous = null)
2020
{
2121
parent::__construct($message, $code, $previous);
2222
}

Hasher/MessageDigestPasswordHasher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function __construct(string $algorithm = 'sha512', bool $encodeHashAsBase
4848
$this->iterations = $iterations;
4949
}
5050

51-
public function hash(string $plainPassword, string $salt = null): string
51+
public function hash(string $plainPassword, ?string $salt = null): string
5252
{
5353
if ($this->isPasswordTooLong($plainPassword)) {
5454
throw new InvalidPasswordException();
@@ -69,7 +69,7 @@ public function hash(string $plainPassword, string $salt = null): string
6969
return $this->encodeHashAsBase64 ? base64_encode($digest) : bin2hex($digest);
7070
}
7171

72-
public function verify(string $hashedPassword, string $plainPassword, string $salt = null): bool
72+
public function verify(string $hashedPassword, string $plainPassword, ?string $salt = null): bool
7373
{
7474
if (\strlen($hashedPassword) !== $this->hashLength || false !== strpos($hashedPassword, '$')) {
7575
return false;

Hasher/MigratingPasswordHasher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ public function __construct(PasswordHasherInterface $bestHasher, PasswordHasherI
3333
$this->extraHashers = $extraHashers;
3434
}
3535

36-
public function hash(string $plainPassword, string $salt = null): string
36+
public function hash(string $plainPassword, ?string $salt = null): string
3737
{
3838
return $this->bestHasher->hash($plainPassword, $salt);
3939
}
4040

41-
public function verify(string $hashedPassword, string $plainPassword, string $salt = null): bool
41+
public function verify(string $hashedPassword, string $plainPassword, ?string $salt = null): bool
4242
{
4343
if ($this->bestHasher->verify($hashedPassword, $plainPassword, $salt)) {
4444
return true;

Hasher/NativePasswordHasher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ final class NativePasswordHasher implements PasswordHasherInterface
3131
/**
3232
* @param string|null $algorithm An algorithm supported by password_hash() or null to use the best available algorithm
3333
*/
34-
public function __construct(int $opsLimit = null, int $memLimit = null, int $cost = null, string $algorithm = null)
34+
public function __construct(?int $opsLimit = null, ?int $memLimit = null, ?int $cost = null, ?string $algorithm = null)
3535
{
3636
$cost = $cost ?? 13;
3737
$opsLimit = $opsLimit ?? max(4, \defined('SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE') ? \SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE : 4);

Hasher/Pbkdf2PasswordHasher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function __construct(string $algorithm = 'sha512', bool $encodeHashAsBase
5959
$this->iterations = $iterations;
6060
}
6161

62-
public function hash(string $plainPassword, string $salt = null): string
62+
public function hash(string $plainPassword, ?string $salt = null): string
6363
{
6464
if ($this->isPasswordTooLong($plainPassword)) {
6565
throw new InvalidPasswordException();
@@ -74,7 +74,7 @@ public function hash(string $plainPassword, string $salt = null): string
7474
return $this->encodeHashAsBase64 ? base64_encode($digest) : bin2hex($digest);
7575
}
7676

77-
public function verify(string $hashedPassword, string $plainPassword, string $salt = null): bool
77+
public function verify(string $hashedPassword, string $plainPassword, ?string $salt = null): bool
7878
{
7979
if (\strlen($hashedPassword) !== $this->encodedLength || false !== strpos($hashedPassword, '$')) {
8080
return false;

Hasher/PlaintextPasswordHasher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct(bool $ignorePasswordCase = false)
3838
/**
3939
* {@inheritdoc}
4040
*/
41-
public function hash(string $plainPassword, string $salt = null): string
41+
public function hash(string $plainPassword, ?string $salt = null): string
4242
{
4343
if ($this->isPasswordTooLong($plainPassword)) {
4444
throw new InvalidPasswordException();
@@ -47,7 +47,7 @@ public function hash(string $plainPassword, string $salt = null): string
4747
return $this->mergePasswordAndSalt($plainPassword, $salt);
4848
}
4949

50-
public function verify(string $hashedPassword, string $plainPassword, string $salt = null): bool
50+
public function verify(string $hashedPassword, string $plainPassword, ?string $salt = null): bool
5151
{
5252
if ($this->isPasswordTooLong($plainPassword)) {
5353
return false;

Hasher/SodiumPasswordHasher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ final class SodiumPasswordHasher implements PasswordHasherInterface
2929
private $opsLimit;
3030
private $memLimit;
3131

32-
public function __construct(int $opsLimit = null, int $memLimit = null)
32+
public function __construct(?int $opsLimit = null, ?int $memLimit = null)
3333
{
3434
if (!self::isSupported()) {
3535
throw new LogicException('Libsodium is not available. You should either install the sodium extension or use a different password hasher.');

LegacyPasswordHasherInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ interface LegacyPasswordHasherInterface extends PasswordHasherInterface
2727
*
2828
* @throws InvalidPasswordException If the plain password is invalid, e.g. excessively long
2929
*/
30-
public function hash(string $plainPassword, string $salt = null): string;
30+
public function hash(string $plainPassword, ?string $salt = null): string;
3131

3232
/**
3333
* Checks that a plain password and a salt match a password hash.
3434
*/
35-
public function verify(string $hashedPassword, string $plainPassword, string $salt = null): bool;
35+
public function verify(string $hashedPassword, string $plainPassword, ?string $salt = null): bool;
3636
}

0 commit comments

Comments
 (0)