Skip to content

Commit f721c77

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

35 files changed

+78
-81
lines changed

Authentication/RememberMe/CacheTokenVerifier.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
*/
1919
class CacheTokenVerifier implements TokenVerifierInterface
2020
{
21-
private $cache;
22-
private $outdatedTokenTtl;
23-
private $cacheKeyPrefix;
21+
private CacheItemPoolInterface $cache;
22+
private int $outdatedTokenTtl;
23+
private string $cacheKeyPrefix;
2424

2525
/**
2626
* @param int $outdatedTokenTtl How long the outdated token should still be considered valid. Defaults

Authentication/RememberMe/InMemoryTokenProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
class InMemoryTokenProvider implements TokenProviderInterface
2222
{
23-
private $tokens = [];
23+
private array $tokens = [];
2424

2525
/**
2626
* {@inheritdoc}

Authentication/RememberMe/PersistentToken.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
*/
1919
final class PersistentToken implements PersistentTokenInterface
2020
{
21-
private $class;
22-
private $userIdentifier;
23-
private $series;
24-
private $tokenValue;
25-
private $lastUsed;
21+
private string $class;
22+
private string $userIdentifier;
23+
private string $series;
24+
private string $tokenValue;
25+
private \DateTime $lastUsed;
2626

2727
public function __construct(string $class, string $userIdentifier, string $series, string $tokenValue, \DateTime $lastUsed)
2828
{

Authentication/Token/AbstractToken.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
*/
2222
abstract class AbstractToken implements TokenInterface, \Serializable
2323
{
24-
private $user;
25-
private $roleNames = [];
26-
private $attributes = [];
24+
private ?UserInterface $user = null;
25+
private array $roleNames = [];
26+
private array $attributes = [];
2727

2828
/**
2929
* @param string[] $roles An array of roles

Authentication/Token/PreAuthenticatedToken.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
class PreAuthenticatedToken extends AbstractToken
2222
{
23-
private $firewallName;
23+
private string $firewallName;
2424

2525
/**
2626
* @param string[] $roles

Authentication/Token/RememberMeToken.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
*/
2121
class RememberMeToken extends AbstractToken
2222
{
23-
private $secret;
24-
private $firewallName;
23+
private string $secret;
24+
private string $firewallName;
2525

2626
/**
2727
* @param string $secret A secret used to make sure the token is created by the app and not by a malicious client

Authentication/Token/Storage/TokenStorage.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
*/
2525
class TokenStorage implements TokenStorageInterface, ResetInterface
2626
{
27-
private $token;
28-
private $initializer;
27+
private ?TokenInterface $token = null;
28+
private ?\Closure $initializer = null;
2929

3030
/**
3131
* {@inheritdoc}
@@ -56,7 +56,7 @@ public function setToken(TokenInterface $token = null)
5656

5757
public function setInitializer(?callable $initializer): void
5858
{
59-
$this->initializer = $initializer;
59+
$this->initializer = null === $initializer || $initializer instanceof \Closure ? $initializer : \Closure::fromCallable($initializer);
6060
}
6161

6262
public function reset()

Authentication/Token/Storage/UsageTrackingTokenStorage.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
*/
2525
final class UsageTrackingTokenStorage implements TokenStorageInterface, ServiceSubscriberInterface
2626
{
27-
private $storage;
28-
private $container;
29-
private $enableUsageTracking = false;
27+
private TokenStorageInterface $storage;
28+
private ContainerInterface $container;
29+
private bool $enableUsageTracking = false;
3030

3131
public function __construct(TokenStorageInterface $storage, ContainerInterface $container)
3232
{

Authentication/Token/SwitchUserToken.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
*/
2121
class SwitchUserToken extends UsernamePasswordToken
2222
{
23-
private $originalToken;
24-
private $originatedFromUri;
23+
private TokenInterface $originalToken;
24+
private ?string $originatedFromUri = null;
2525

2626
/**
2727
* @param $user The username (like a nickname, email address, etc.), or a UserInterface instance or an object implementing a __toString method

Authentication/Token/UsernamePasswordToken.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
class UsernamePasswordToken extends AbstractToken
2222
{
23-
private $firewallName;
23+
private string $firewallName;
2424

2525
public function __construct(UserInterface $user, string $firewallName, array $roles = [])
2626
{

0 commit comments

Comments
 (0)