Skip to content

Commit 5667246

Browse files
committed
[PasswordHasher] Add types to private properties
Signed-off-by: Alexander M. Turek <me@derrabus.de>
1 parent 02a4808 commit 5667246

9 files changed

+20
-20
lines changed

Command/UserPasswordHashCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ class UserPasswordHashCommand extends Command
3737
protected static $defaultName = 'security:hash-password';
3838
protected static $defaultDescription = 'Hash a user password';
3939

40-
private $hasherFactory;
41-
private $userClasses;
40+
private PasswordHasherFactoryInterface $hasherFactory;
41+
private array $userClasses;
4242

4343
public function __construct(PasswordHasherFactoryInterface $hasherFactory, array $userClasses = [])
4444
{

Hasher/MessageDigestPasswordHasher.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ class MessageDigestPasswordHasher implements LegacyPasswordHasherInterface
2424
{
2525
use CheckPasswordLengthTrait;
2626

27-
private $algorithm;
28-
private $encodeHashAsBase64;
29-
private $iterations = 1;
30-
private $hashLength = -1;
27+
private string $algorithm;
28+
private bool $encodeHashAsBase64;
29+
private int $iterations = 1;
30+
private int $hashLength = -1;
3131

3232
/**
3333
* @param string $algorithm The digest algorithm to use

Hasher/MigratingPasswordHasher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
*/
2525
final class MigratingPasswordHasher implements PasswordHasherInterface
2626
{
27-
private $bestHasher;
28-
private $extraHashers;
27+
private PasswordHasherInterface $bestHasher;
28+
private array $extraHashers;
2929

3030
public function __construct(PasswordHasherInterface $bestHasher, PasswordHasherInterface ...$extraHashers)
3131
{

Hasher/NativePasswordHasher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ final class NativePasswordHasher implements PasswordHasherInterface
2525
{
2626
use CheckPasswordLengthTrait;
2727

28-
private $algorithm = \PASSWORD_BCRYPT;
29-
private $options;
28+
private string $algorithm = \PASSWORD_BCRYPT;
29+
private array $options;
3030

3131
/**
3232
* @param string|null $algorithm An algorithm supported by password_hash() or null to use the best available algorithm

Hasher/PasswordHasherFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*/
2424
class PasswordHasherFactory implements PasswordHasherFactoryInterface
2525
{
26-
private $passwordHashers;
26+
private array $passwordHashers;
2727

2828
/**
2929
* @param array<string, PasswordHasherInterface|array> $passwordHashers

Hasher/Pbkdf2PasswordHasher.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ final class Pbkdf2PasswordHasher implements LegacyPasswordHasherInterface
3232
{
3333
use CheckPasswordLengthTrait;
3434

35-
private $algorithm;
36-
private $encodeHashAsBase64;
37-
private $iterations = 1;
38-
private $length;
39-
private $encodedLength = -1;
35+
private string $algorithm;
36+
private bool $encodeHashAsBase64;
37+
private int $iterations = 1;
38+
private int $length;
39+
private int $encodedLength = -1;
4040

4141
/**
4242
* @param string $algorithm The digest algorithm to use

Hasher/PlaintextPasswordHasher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class PlaintextPasswordHasher implements LegacyPasswordHasherInterface
2525
{
2626
use CheckPasswordLengthTrait;
2727

28-
private $ignorePasswordCase;
28+
private bool $ignorePasswordCase;
2929

3030
/**
3131
* @param bool $ignorePasswordCase Compare password case-insensitive

Hasher/SodiumPasswordHasher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ final class SodiumPasswordHasher implements PasswordHasherInterface
2626
{
2727
use CheckPasswordLengthTrait;
2828

29-
private $opsLimit;
30-
private $memLimit;
29+
private int $opsLimit;
30+
private int $memLimit;
3131

3232
public function __construct(int $opsLimit = null, int $memLimit = null)
3333
{

Hasher/UserPasswordHasher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*/
2424
class UserPasswordHasher implements UserPasswordHasherInterface
2525
{
26-
private $hasherFactory;
26+
private PasswordHasherFactoryInterface $hasherFactory;
2727

2828
public function __construct(PasswordHasherFactoryInterface $hasherFactory)
2929
{

0 commit comments

Comments
 (0)