Skip to content

Commit 175b36e

Browse files
Replace more docblocks by type-hints
1 parent b48e3e0 commit 175b36e

29 files changed

+34
-80
lines changed

Authentication/AuthenticationProviderManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ class AuthenticationProviderManager implements AuthenticationManagerInterface
4040
*
4141
* @throws \InvalidArgumentException
4242
*/
43-
public function __construct($providers, $eraseCredentials = true)
43+
public function __construct(iterable $providers, bool $eraseCredentials = true)
4444
{
4545
if (!$providers) {
4646
throw new \InvalidArgumentException('You must at least add one authentication provider.');
4747
}
4848

4949
$this->providers = $providers;
50-
$this->eraseCredentials = (bool) $eraseCredentials;
50+
$this->eraseCredentials = $eraseCredentials;
5151
}
5252

5353
public function setEventDispatcher(EventDispatcherInterface $dispatcher)

Authentication/AuthenticationTrustResolver.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@ class AuthenticationTrustResolver implements AuthenticationTrustResolverInterfac
2323
private $anonymousClass;
2424
private $rememberMeClass;
2525

26-
/**
27-
* @param string $anonymousClass
28-
* @param string $rememberMeClass
29-
*/
30-
public function __construct($anonymousClass, $rememberMeClass)
26+
public function __construct(string $anonymousClass, string $rememberMeClass)
3127
{
3228
$this->anonymousClass = $anonymousClass;
3329
$this->rememberMeClass = $rememberMeClass;

Authentication/Provider/AnonymousAuthenticationProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class AnonymousAuthenticationProvider implements AuthenticationProviderInterface
3434
/**
3535
* @param string $secret The secret shared with the AnonymousToken
3636
*/
37-
public function __construct($secret)
37+
public function __construct(string $secret)
3838
{
3939
$this->secret = $secret;
4040
}

Authentication/Provider/DaoAuthenticationProvider.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,7 @@ class DaoAuthenticationProvider extends UserAuthenticationProvider
3131
private $encoderFactory;
3232
private $userProvider;
3333

34-
/**
35-
* @param UserProviderInterface $userProvider An UserProviderInterface instance
36-
* @param UserCheckerInterface $userChecker An UserCheckerInterface instance
37-
* @param string $providerKey The provider key
38-
* @param EncoderFactoryInterface $encoderFactory An EncoderFactoryInterface instance
39-
* @param bool $hideUserNotFoundExceptions Whether to hide user not found exception or not
40-
*/
41-
public function __construct(UserProviderInterface $userProvider, UserCheckerInterface $userChecker, $providerKey, EncoderFactoryInterface $encoderFactory, $hideUserNotFoundExceptions = true)
34+
public function __construct(UserProviderInterface $userProvider, UserCheckerInterface $userChecker, string $providerKey, EncoderFactoryInterface $encoderFactory, bool $hideUserNotFoundExceptions = true)
4235
{
4336
parent::__construct($userChecker, $providerKey, $hideUserNotFoundExceptions);
4437

Authentication/Provider/LdapBindAuthenticationProvider.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,7 @@ class LdapBindAuthenticationProvider extends UserAuthenticationProvider
3535
private $dnString;
3636
private $queryString;
3737

38-
/**
39-
* @param UserProviderInterface $userProvider A UserProvider
40-
* @param UserCheckerInterface $userChecker A UserChecker
41-
* @param string $providerKey The provider key
42-
* @param LdapInterface $ldap A Ldap client
43-
* @param string $dnString A string used to create the bind DN
44-
* @param bool $hideUserNotFoundExceptions Whether to hide user not found exception or not
45-
*/
46-
public function __construct(UserProviderInterface $userProvider, UserCheckerInterface $userChecker, $providerKey, LdapInterface $ldap, $dnString = '{username}', $hideUserNotFoundExceptions = true)
38+
public function __construct(UserProviderInterface $userProvider, UserCheckerInterface $userChecker, string $providerKey, LdapInterface $ldap, string $dnString = '{username}', bool $hideUserNotFoundExceptions = true)
4739
{
4840
parent::__construct($userChecker, $providerKey, $hideUserNotFoundExceptions);
4941

Authentication/Provider/PreAuthenticatedAuthenticationProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class PreAuthenticatedAuthenticationProvider implements AuthenticationProviderIn
3434
private $userChecker;
3535
private $providerKey;
3636

37-
public function __construct(UserProviderInterface $userProvider, UserCheckerInterface $userChecker, $providerKey)
37+
public function __construct(UserProviderInterface $userProvider, UserCheckerInterface $userChecker, string $providerKey)
3838
{
3939
$this->userProvider = $userProvider;
4040
$this->userChecker = $userChecker;

Authentication/Provider/RememberMeAuthenticationProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class RememberMeAuthenticationProvider implements AuthenticationProviderInterfac
2828
* @param string $secret A secret
2929
* @param string $providerKey A provider secret
3030
*/
31-
public function __construct(UserCheckerInterface $userChecker, $secret, $providerKey)
31+
public function __construct(UserCheckerInterface $userChecker, string $secret, string $providerKey)
3232
{
3333
$this->userChecker = $userChecker;
3434
$this->secret = $secret;

Authentication/Provider/SimpleAuthenticationProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class SimpleAuthenticationProvider implements AuthenticationProviderInterface
2525
private $userProvider;
2626
private $providerKey;
2727

28-
public function __construct(SimpleAuthenticatorInterface $simpleAuthenticator, UserProviderInterface $userProvider, $providerKey)
28+
public function __construct(SimpleAuthenticatorInterface $simpleAuthenticator, UserProviderInterface $userProvider, string $providerKey)
2929
{
3030
$this->simpleAuthenticator = $simpleAuthenticator;
3131
$this->userProvider = $userProvider;

Authentication/Provider/UserAuthenticationProvider.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,9 @@ abstract class UserAuthenticationProvider implements AuthenticationProviderInter
3333
private $providerKey;
3434

3535
/**
36-
* @param UserCheckerInterface $userChecker An UserCheckerInterface interface
37-
* @param string $providerKey A provider key
38-
* @param bool $hideUserNotFoundExceptions Whether to hide user not found exception or not
39-
*
4036
* @throws \InvalidArgumentException
4137
*/
42-
public function __construct(UserCheckerInterface $userChecker, $providerKey, $hideUserNotFoundExceptions = true)
38+
public function __construct(UserCheckerInterface $userChecker, string $providerKey, bool $hideUserNotFoundExceptions = true)
4339
{
4440
if (empty($providerKey)) {
4541
throw new \InvalidArgumentException('$providerKey must not be empty.');

Authentication/Token/AnonymousToken.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class AnonymousToken extends AbstractToken
2727
* @param string|object $user The user can be a UserInterface instance, or an object implementing a __toString method or the username as a regular string
2828
* @param Role[] $roles An array of roles
2929
*/
30-
public function __construct($secret, $user, array $roles = array())
30+
public function __construct(string $secret, $user, array $roles = array())
3131
{
3232
parent::__construct($roles);
3333

Authentication/Token/PreAuthenticatedToken.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class PreAuthenticatedToken extends AbstractToken
2727
* @param string $providerKey The provider key
2828
* @param (Role|string)[] $roles An array of roles
2929
*/
30-
public function __construct($user, $credentials, $providerKey, array $roles = array())
30+
public function __construct($user, $credentials, string $providerKey, array $roles = array())
3131
{
3232
parent::__construct($roles);
3333

Authentication/Token/RememberMeToken.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class RememberMeToken extends AbstractToken
3030
*
3131
* @throws \InvalidArgumentException
3232
*/
33-
public function __construct(UserInterface $user, $providerKey, $secret)
33+
public function __construct(UserInterface $user, string $providerKey, string $secret)
3434
{
3535
parent::__construct($user->getRoles());
3636

Authentication/Token/UsernamePasswordToken.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class UsernamePasswordToken extends AbstractToken
2929
*
3030
* @throws \InvalidArgumentException
3131
*/
32-
public function __construct($user, $credentials, $providerKey, array $roles = array())
32+
public function __construct($user, $credentials, string $providerKey, array $roles = array())
3333
{
3434
parent::__construct($roles);
3535

Authorization/AccessDecisionManager.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class AccessDecisionManager implements AccessDecisionManagerInterface
3939
*
4040
* @throws \InvalidArgumentException
4141
*/
42-
public function __construct($voters = array(), $strategy = self::STRATEGY_AFFIRMATIVE, $allowIfAllAbstainDecisions = false, $allowIfEqualGrantedDeniedDecisions = true)
42+
public function __construct(iterable $voters = array(), string $strategy = self::STRATEGY_AFFIRMATIVE, bool $allowIfAllAbstainDecisions = false, bool $allowIfEqualGrantedDeniedDecisions = true)
4343
{
4444
$strategyMethod = 'decide'.ucfirst($strategy);
4545
if (!is_callable(array($this, $strategyMethod))) {
@@ -48,8 +48,8 @@ public function __construct($voters = array(), $strategy = self::STRATEGY_AFFIRM
4848

4949
$this->voters = $voters;
5050
$this->strategy = $strategyMethod;
51-
$this->allowIfAllAbstainDecisions = (bool) $allowIfAllAbstainDecisions;
52-
$this->allowIfEqualGrantedDeniedDecisions = (bool) $allowIfEqualGrantedDeniedDecisions;
51+
$this->allowIfAllAbstainDecisions = $allowIfAllAbstainDecisions;
52+
$this->allowIfEqualGrantedDeniedDecisions = $allowIfEqualGrantedDeniedDecisions;
5353
}
5454

5555
/**

Authorization/AuthorizationChecker.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,7 @@ class AuthorizationChecker implements AuthorizationCheckerInterface
3030
private $authenticationManager;
3131
private $alwaysAuthenticate;
3232

33-
/**
34-
* @param TokenStorageInterface $tokenStorage
35-
* @param AuthenticationManagerInterface $authenticationManager An AuthenticationManager instance
36-
* @param AccessDecisionManagerInterface $accessDecisionManager An AccessDecisionManager instance
37-
* @param bool $alwaysAuthenticate
38-
*/
39-
public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, AccessDecisionManagerInterface $accessDecisionManager, $alwaysAuthenticate = false)
33+
public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, AccessDecisionManagerInterface $accessDecisionManager, bool $alwaysAuthenticate = false)
4034
{
4135
$this->tokenStorage = $tokenStorage;
4236
$this->authenticationManager = $authenticationManager;

Authorization/Voter/RoleHierarchyVoter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class RoleHierarchyVoter extends RoleVoter
2424
{
2525
private $roleHierarchy;
2626

27-
public function __construct(RoleHierarchyInterface $roleHierarchy, $prefix = 'ROLE_')
27+
public function __construct(RoleHierarchyInterface $roleHierarchy, string $prefix = 'ROLE_')
2828
{
2929
$this->roleHierarchy = $roleHierarchy;
3030

Authorization/Voter/RoleVoter.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ class RoleVoter implements VoterInterface
2323
{
2424
private $prefix;
2525

26-
/**
27-
* @param string $prefix The role prefix
28-
*/
29-
public function __construct($prefix = 'ROLE_')
26+
public function __construct(string $prefix = 'ROLE_')
3027
{
3128
$this->prefix = $prefix;
3229
}

Encoder/BCryptPasswordEncoder.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@ class BCryptPasswordEncoder extends BasePasswordEncoder implements SelfSaltingEn
2929
* @throws \RuntimeException When no BCrypt encoder is available
3030
* @throws \InvalidArgumentException if cost is out of range
3131
*/
32-
public function __construct($cost)
32+
public function __construct(int $cost)
3333
{
34-
$cost = (int) $cost;
3534
if ($cost < 4 || $cost > 31) {
3635
throw new \InvalidArgumentException('Cost must be in the range of 4-31.');
3736
}

Encoder/MessageDigestPasswordEncoder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class MessageDigestPasswordEncoder extends BasePasswordEncoder
2929
* @param bool $encodeHashAsBase64 Whether to base64 encode the password hash
3030
* @param int $iterations The number of iterations to use to stretch the password hash
3131
*/
32-
public function __construct($algorithm = 'sha512', $encodeHashAsBase64 = true, $iterations = 5000)
32+
public function __construct(string $algorithm = 'sha512', bool $encodeHashAsBase64 = true, int $iterations = 5000)
3333
{
3434
$this->algorithm = $algorithm;
3535
$this->encodeHashAsBase64 = $encodeHashAsBase64;

Encoder/Pbkdf2PasswordEncoder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Pbkdf2PasswordEncoder extends BasePasswordEncoder
3939
* @param int $iterations The number of iterations to use to stretch the password hash
4040
* @param int $length Length of derived key to create
4141
*/
42-
public function __construct($algorithm = 'sha512', $encodeHashAsBase64 = true, $iterations = 1000, $length = 40)
42+
public function __construct(string $algorithm = 'sha512', bool $encodeHashAsBase64 = true, int $iterations = 1000, int $length = 40)
4343
{
4444
$this->algorithm = $algorithm;
4545
$this->encodeHashAsBase64 = $encodeHashAsBase64;

Encoder/PlaintextPasswordEncoder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class PlaintextPasswordEncoder extends BasePasswordEncoder
2525
/**
2626
* @param bool $ignorePasswordCase Compare password case-insensitive
2727
*/
28-
public function __construct($ignorePasswordCase = false)
28+
public function __construct(bool $ignorePasswordCase = false)
2929
{
3030
$this->ignorePasswordCase = $ignorePasswordCase;
3131
}

Exception/AccessDeniedException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class AccessDeniedException extends \RuntimeException
2121
private $attributes = array();
2222
private $subject;
2323

24-
public function __construct($message = 'Access Denied.', \Exception $previous = null)
24+
public function __construct(string $message = 'Access Denied.', \Exception $previous = null)
2525
{
2626
parent::__construct($message, 403, $previous);
2727
}

Exception/CustomUserMessageAuthenticationException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class CustomUserMessageAuthenticationException extends AuthenticationException
2626

2727
private $messageData = array();
2828

29-
public function __construct($message = '', array $messageData = array(), $code = 0, \Exception $previous = null)
29+
public function __construct(string $message = '', array $messageData = array(), int $code = 0, \Exception $previous = null)
3030
{
3131
parent::__construct($message, $code, $previous);
3232

Exception/LogoutException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919
class LogoutException extends \RuntimeException
2020
{
21-
public function __construct($message = 'Logout Exception', \Exception $previous = null)
21+
public function __construct(string $message = 'Logout Exception', \Exception $previous = null)
2222
{
2323
parent::__construct($message, 403, $previous);
2424
}

Role/Role.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,9 @@ class Role
2020
{
2121
private $role;
2222

23-
/**
24-
* @param string $role The role name
25-
*/
26-
public function __construct($role)
23+
public function __construct(string $role)
2724
{
28-
$this->role = (string) $role;
25+
$this->role = $role;
2926
}
3027

3128
/**

Role/SwitchUserRole.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class SwitchUserRole extends Role
2727
* @param string $role The role as a string
2828
* @param TokenInterface $source The original token
2929
*/
30-
public function __construct($role, TokenInterface $source)
30+
public function __construct(string $role, TokenInterface $source)
3131
{
3232
parent::__construct($role);
3333

Tests/Authentication/Token/RememberMeTokenTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function testConstructor()
3030
}
3131

3232
/**
33-
* @expectedException \InvalidArgumentException
33+
* @expectedException \TypeError
3434
*/
3535
public function testConstructorSecretCannotBeNull()
3636
{
@@ -57,7 +57,7 @@ protected function getUser($roles = array('ROLE_FOO'))
5757
{
5858
$user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
5959
$user
60-
->expects($this->once())
60+
->expects($this->any())
6161
->method('getRoles')
6262
->will($this->returnValue($roles))
6363
;

User/LdapUserProvider.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,7 @@ class LdapUserProvider implements UserProviderInterface
3535
private $defaultSearch;
3636
private $passwordAttribute;
3737

38-
/**
39-
* @param LdapInterface $ldap
40-
* @param string $baseDn
41-
* @param string $searchDn
42-
* @param string $searchPassword
43-
* @param array $defaultRoles
44-
* @param string $uidKey
45-
* @param string $filter
46-
* @param string $passwordAttribute
47-
*/
48-
public function __construct(LdapInterface $ldap, $baseDn, $searchDn = null, $searchPassword = null, array $defaultRoles = array(), $uidKey = 'sAMAccountName', $filter = '({uid_key}={username})', $passwordAttribute = null)
38+
public function __construct(LdapInterface $ldap, string $baseDn, string $searchDn = null, string $searchPassword = null, array $defaultRoles = array(), string $uidKey = 'sAMAccountName', string $filter = '({uid_key}={username})', string $passwordAttribute = null)
4939
{
5040
if (null === $uidKey) {
5141
$uidKey = 'sAMAccountName';

User/User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ final class User implements AdvancedUserInterface
2828
private $accountNonLocked;
2929
private $roles;
3030

31-
public function __construct($username, $password, array $roles = array(), $enabled = true, $userNonExpired = true, $credentialsNonExpired = true, $userNonLocked = true)
31+
public function __construct(?string $username, ?string $password, array $roles = array(), bool $enabled = true, bool $userNonExpired = true, bool $credentialsNonExpired = true, bool $userNonLocked = true)
3232
{
3333
if ('' === $username || null === $username) {
3434
throw new \InvalidArgumentException('The username cannot be empty.');

0 commit comments

Comments
 (0)