Skip to content

Commit 44a6d77

Browse files
committed
[Security] Add types to private properties
Signed-off-by: Alexander M. Turek <[email protected]>
1 parent cb696c8 commit 44a6d77

File tree

67 files changed

+206
-215
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+206
-215
lines changed

AccessMap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
class AccessMap implements AccessMapInterface
2424
{
25-
private $map = [];
25+
private array $map = [];
2626

2727
/**
2828
* @param array $attributes An array of attributes to pass to the access decision manager (like roles)

Authentication/AuthenticationUtils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*/
2424
class AuthenticationUtils
2525
{
26-
private $requestStack;
26+
private RequestStack $requestStack;
2727

2828
public function __construct(RequestStack $requestStack)
2929
{

Authentication/AuthenticatorManager.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@
4545
*/
4646
class AuthenticatorManager implements AuthenticatorManagerInterface, UserAuthenticatorInterface
4747
{
48-
private $authenticators;
49-
private $tokenStorage;
50-
private $eventDispatcher;
51-
private $eraseCredentials;
52-
private $logger;
53-
private $firewallName;
54-
private $hideUserNotFoundExceptions;
55-
private $requiredBadges;
48+
private iterable $authenticators;
49+
private TokenStorageInterface $tokenStorage;
50+
private EventDispatcherInterface $eventDispatcher;
51+
private bool $eraseCredentials;
52+
private ?LoggerInterface $logger;
53+
private string $firewallName;
54+
private bool $hideUserNotFoundExceptions;
55+
private array $requiredBadges;
5656

5757
/**
58-
* @param AuthenticatorInterface[] $authenticators
58+
* @param iterable<mixed, AuthenticatorInterface> $authenticators
5959
*/
6060
public function __construct(iterable $authenticators, TokenStorageInterface $tokenStorage, EventDispatcherInterface $eventDispatcher, string $firewallName, LoggerInterface $logger = null, bool $eraseCredentials = true, bool $hideUserNotFoundExceptions = true, array $requiredBadges = [])
6161
{

Authentication/CustomAuthenticationFailureHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
class CustomAuthenticationFailureHandler implements AuthenticationFailureHandlerInterface
2222
{
23-
private $handler;
23+
private AuthenticationFailureHandlerInterface $handler;
2424

2525
/**
2626
* @param array $options Options for processing a successful authentication attempt

Authentication/CustomAuthenticationSuccessHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
class CustomAuthenticationSuccessHandler implements AuthenticationSuccessHandlerInterface
2222
{
23-
private $handler;
23+
private AuthenticationSuccessHandlerInterface $handler;
2424

2525
/**
2626
* @param array $options Options for processing a successful authentication attempt

Authenticator/AbstractPreAuthenticatedAuthenticator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636
*/
3737
abstract class AbstractPreAuthenticatedAuthenticator implements InteractiveAuthenticatorInterface
3838
{
39-
private $userProvider;
40-
private $tokenStorage;
41-
private $firewallName;
42-
private $logger;
39+
private UserProviderInterface $userProvider;
40+
private TokenStorageInterface $tokenStorage;
41+
private string $firewallName;
42+
private ?LoggerInterface $logger;
4343

4444
public function __construct(UserProviderInterface $userProvider, TokenStorageInterface $tokenStorage, string $firewallName, LoggerInterface $logger = null)
4545
{

Authenticator/Debug/TraceableAuthenticator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
*/
3030
final class TraceableAuthenticator implements AuthenticatorInterface, InteractiveAuthenticatorInterface, AuthenticationEntryPointInterface
3131
{
32-
private $authenticator;
33-
private $passport;
34-
private $duration;
35-
private $stub;
32+
private AuthenticatorInterface $authenticator;
33+
private ?Passport $passport = null;
34+
private ?float $duration = null;
35+
private ClassStub|string $stub;
3636

3737
public function __construct(AuthenticatorInterface $authenticator)
3838
{

Authenticator/Debug/TraceableAuthenticatorManagerListener.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
*/
2525
final class TraceableAuthenticatorManagerListener extends AbstractListener
2626
{
27-
private $authenticationManagerListener;
28-
private $authenticatorsInfo = [];
29-
private $hasVardumper;
27+
private AuthenticatorManagerListener $authenticationManagerListener;
28+
private array $authenticatorsInfo = [];
29+
private bool $hasVardumper;
3030

3131
public function __construct(AuthenticatorManagerListener $authenticationManagerListener)
3232
{

Authenticator/FormLoginAuthenticator.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@
4141
*/
4242
class FormLoginAuthenticator extends AbstractLoginFormAuthenticator
4343
{
44-
private $httpUtils;
45-
private $userProvider;
46-
private $successHandler;
47-
private $failureHandler;
48-
private $options;
49-
private $httpKernel;
44+
private HttpUtils $httpUtils;
45+
private UserProviderInterface $userProvider;
46+
private AuthenticationSuccessHandlerInterface $successHandler;
47+
private AuthenticationFailureHandlerInterface $failureHandler;
48+
private array $options;
49+
private HttpKernelInterface $httpKernel;
5050

5151
public function __construct(HttpUtils $httpUtils, UserProviderInterface $userProvider, AuthenticationSuccessHandlerInterface $successHandler, AuthenticationFailureHandlerInterface $failureHandler, array $options)
5252
{

Authenticator/HttpBasicAuthenticator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
*/
3434
class HttpBasicAuthenticator implements AuthenticatorInterface, AuthenticationEntryPointInterface
3535
{
36-
private $realmName;
37-
private $userProvider;
38-
private $logger;
36+
private string $realmName;
37+
private UserProviderInterface $userProvider;
38+
private ?LoggerInterface $logger;
3939

4040
public function __construct(string $realmName, UserProviderInterface $userProvider, LoggerInterface $logger = null)
4141
{

Authenticator/JsonLoginAuthenticator.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,13 @@
4545
*/
4646
class JsonLoginAuthenticator implements InteractiveAuthenticatorInterface
4747
{
48-
private $options;
49-
private $httpUtils;
50-
private $userProvider;
51-
private $propertyAccessor;
52-
private $successHandler;
53-
private $failureHandler;
54-
55-
/**
56-
* @var TranslatorInterface|null
57-
*/
58-
private $translator;
48+
private array $options;
49+
private HttpUtils $httpUtils;
50+
private UserProviderInterface $userProvider;
51+
private PropertyAccessorInterface $propertyAccessor;
52+
private ?AuthenticationSuccessHandlerInterface $successHandler;
53+
private ?AuthenticationFailureHandlerInterface $failureHandler;
54+
private ?TranslatorInterface $translator = null;
5955

6056
public function __construct(HttpUtils $httpUtils, UserProviderInterface $userProvider, AuthenticationSuccessHandlerInterface $successHandler = null, AuthenticationFailureHandlerInterface $failureHandler = null, array $options = [], PropertyAccessorInterface $propertyAccessor = null)
6157
{

Authenticator/LoginLinkAuthenticator.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
*/
3232
final class LoginLinkAuthenticator extends AbstractAuthenticator implements InteractiveAuthenticatorInterface
3333
{
34-
private $loginLinkHandler;
35-
private $httpUtils;
36-
private $successHandler;
37-
private $failureHandler;
38-
private $options;
34+
private LoginLinkHandlerInterface $loginLinkHandler;
35+
private HttpUtils $httpUtils;
36+
private AuthenticationSuccessHandlerInterface $successHandler;
37+
private AuthenticationFailureHandlerInterface $failureHandler;
38+
private array $options;
3939

4040
public function __construct(LoginLinkHandlerInterface $loginLinkHandler, HttpUtils $httpUtils, AuthenticationSuccessHandlerInterface $successHandler, AuthenticationFailureHandlerInterface $failureHandler, array $options)
4141
{

Authenticator/Passport/Badge/CsrfTokenBadge.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
*/
2525
class CsrfTokenBadge implements BadgeInterface
2626
{
27-
private $resolved = false;
28-
private $csrfTokenId;
29-
private $csrfToken;
27+
private bool $resolved = false;
28+
private string $csrfTokenId;
29+
private ?string $csrfToken;
3030

3131
/**
3232
* @param string $csrfTokenId An arbitrary string used to generate the value of the CSRF token.

Authenticator/Passport/Badge/PasswordUpgradeBadge.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
*/
2626
class PasswordUpgradeBadge implements BadgeInterface
2727
{
28-
private $plaintextPassword;
29-
private $passwordUpgrader;
28+
private ?string $plaintextPassword = null;
29+
private ?PasswordUpgraderInterface $passwordUpgrader;
3030

3131
/**
3232
* @param string $plaintextPassword The presented password, used in the rehash

Authenticator/Passport/Badge/RememberMeBadge.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*/
2727
class RememberMeBadge implements BadgeInterface
2828
{
29-
private $enabled = false;
29+
private bool $enabled = false;
3030

3131
/**
3232
* Enables remember-me cookie creation.

Authenticator/Passport/Badge/UserBadge.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@
2626
*/
2727
class UserBadge implements BadgeInterface
2828
{
29-
private $userIdentifier;
29+
private string $userIdentifier;
30+
/** @var callable|null */
3031
private $userLoader;
31-
private $user;
32+
private UserInterface $user;
3233

3334
/**
3435
* Initializes the user badge.
@@ -59,15 +60,17 @@ public function getUserIdentifier(): string
5960
*/
6061
public function getUser(): UserInterface
6162
{
62-
if (null === $this->user) {
63+
if (!isset($this->user)) {
6364
if (null === $this->userLoader) {
6465
throw new \LogicException(sprintf('No user loader is configured, did you forget to register the "%s" listener?', UserProviderListener::class));
6566
}
6667

67-
$this->user = ($this->userLoader)($this->userIdentifier);
68-
if (!$this->user instanceof UserInterface) {
68+
$user = ($this->userLoader)($this->userIdentifier);
69+
if (!$user instanceof UserInterface) {
6970
throw new AuthenticationServiceException(sprintf('The user provider must return a UserInterface object, "%s" given.', get_debug_type($this->user)));
7071
}
72+
73+
$this->user = $user;
7174
}
7275

7376
return $this->user;

Authenticator/Passport/Credentials/CustomCredentials.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
*/
2424
class CustomCredentials implements CredentialsInterface
2525
{
26-
private $customCredentialsChecker;
27-
private $credentials;
28-
private $resolved = false;
26+
private \Closure $customCredentialsChecker;
27+
private mixed $credentials;
28+
private bool $resolved = false;
2929

3030
/**
3131
* @param callable $customCredentialsChecker the check function. If this function does not return `true`, a
@@ -34,7 +34,7 @@ class CustomCredentials implements CredentialsInterface
3434
*/
3535
public function __construct(callable $customCredentialsChecker, mixed $credentials)
3636
{
37-
$this->customCredentialsChecker = $customCredentialsChecker;
37+
$this->customCredentialsChecker = $customCredentialsChecker instanceof \Closure ? $customCredentialsChecker : \Closure::fromCallable($customCredentialsChecker);
3838
$this->credentials = $credentials;
3939
}
4040

Authenticator/Passport/Credentials/PasswordCredentials.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
*/
2626
class PasswordCredentials implements CredentialsInterface
2727
{
28-
private $password;
29-
private $resolved = false;
28+
private ?string $password = null;
29+
private bool $resolved = false;
3030

3131
public function __construct(string $password)
3232
{

Authenticator/Passport/Passport.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class Passport
2525
{
2626
protected $user;
2727

28-
private $badges = [];
29-
private $attributes = [];
28+
private array $badges = [];
29+
private array $attributes = [];
3030

3131
/**
3232
* @param CredentialsInterface $credentials the credentials to check for this authentication, use

Authenticator/RememberMeAuthenticator.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@
4343
*/
4444
class RememberMeAuthenticator implements InteractiveAuthenticatorInterface
4545
{
46-
private $rememberMeHandler;
47-
private $secret;
48-
private $tokenStorage;
49-
private $cookieName;
50-
private $logger;
46+
private RememberMeHandlerInterface $rememberMeHandler;
47+
private string $secret;
48+
private TokenStorageInterface $tokenStorage;
49+
private string $cookieName;
50+
private ?LoggerInterface $logger;
5151

5252
public function __construct(RememberMeHandlerInterface $rememberMeHandler, string $secret, TokenStorageInterface $tokenStorage, string $cookieName, LoggerInterface $logger = null)
5353
{

Authenticator/RemoteUserAuthenticator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
*/
3131
class RemoteUserAuthenticator extends AbstractPreAuthenticatedAuthenticator
3232
{
33-
private $userKey;
33+
private string $userKey;
3434

3535
public function __construct(UserProviderInterface $userProvider, TokenStorageInterface $tokenStorage, string $firewallName, string $userKey = 'REMOTE_USER', LoggerInterface $logger = null)
3636
{

Authenticator/Token/PostAuthenticationToken.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
class PostAuthenticationToken extends AbstractToken
1818
{
19-
private $firewallName;
19+
private string $firewallName;
2020

2121
/**
2222
* @param string[] $roles An array of roles

Authenticator/X509Authenticator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
*/
2929
class X509Authenticator extends AbstractPreAuthenticatedAuthenticator
3030
{
31-
private $userKey;
32-
private $credentialsKey;
31+
private string $userKey;
32+
private string $credentialsKey;
3333

3434
public function __construct(UserProviderInterface $userProvider, TokenStorageInterface $tokenStorage, string $firewallName, string $userKey = 'SSL_CLIENT_S_DN_Email', string $credentialsKey = 'SSL_CLIENT_S_DN', LoggerInterface $logger = null)
3535
{

Controller/UserValueResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*/
2727
final class UserValueResolver implements ArgumentValueResolverInterface
2828
{
29-
private $tokenStorage;
29+
private TokenStorageInterface $tokenStorage;
3030

3131
public function __construct(TokenStorageInterface $tokenStorage)
3232
{

Event/AuthenticationTokenCreatedEvent.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
*/
2323
class AuthenticationTokenCreatedEvent extends Event
2424
{
25-
private $authenticatedToken;
26-
private $passport;
25+
private TokenInterface $authenticatedToken;
26+
private Passport $passport;
2727

2828
public function __construct(TokenInterface $token, Passport $passport)
2929
{

Event/CheckPassportEvent.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
*/
2727
class CheckPassportEvent extends Event
2828
{
29-
private $authenticator;
30-
private $passport;
29+
private AuthenticatorInterface $authenticator;
30+
private Passport $passport;
3131

3232
public function __construct(AuthenticatorInterface $authenticator, Passport $passport)
3333
{

Event/InteractiveLoginEvent.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
*/
2121
final class InteractiveLoginEvent extends Event
2222
{
23-
private $request;
24-
private $authenticationToken;
23+
private Request $request;
24+
private TokenInterface $authenticationToken;
2525

2626
public function __construct(Request $request, TokenInterface $authenticationToken)
2727
{

Event/LazyResponseEvent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525
final class LazyResponseEvent extends RequestEvent
2626
{
27-
private $event;
27+
private parent $event;
2828

2929
public function __construct(parent $event)
3030
{

0 commit comments

Comments
 (0)