Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 71cd16c

Browse files
[Security] add return types
1 parent 9004e35 commit 71cd16c

File tree

103 files changed

+206
-203
lines changed

Some content is hidden

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

103 files changed

+206
-203
lines changed

src/Symfony/Component/Security/Core/Authentication/AuthenticationProviderManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function setEventDispatcher(EventDispatcherInterface $dispatcher)
7070
/**
7171
* {@inheritdoc}
7272
*/
73-
public function authenticate(TokenInterface $token)
73+
public function authenticate(TokenInterface $token): TokenInterface
7474
{
7575
$lastException = null;
7676
$result = null;

src/Symfony/Component/Security/Core/Authentication/AuthenticationTrustResolver.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class AuthenticationTrustResolver implements AuthenticationTrustResolverInterfac
2626
/**
2727
* {@inheritdoc}
2828
*/
29-
public function isAnonymous(TokenInterface $token = null)
29+
public function isAnonymous(TokenInterface $token = null): bool
3030
{
3131
if (null === $token) {
3232
return false;
@@ -38,7 +38,7 @@ public function isAnonymous(TokenInterface $token = null)
3838
/**
3939
* {@inheritdoc}
4040
*/
41-
public function isRememberMe(TokenInterface $token = null)
41+
public function isRememberMe(TokenInterface $token = null): bool
4242
{
4343
if (null === $token) {
4444
return false;
@@ -50,7 +50,7 @@ public function isRememberMe(TokenInterface $token = null)
5050
/**
5151
* {@inheritdoc}
5252
*/
53-
public function isFullFledged(TokenInterface $token = null)
53+
public function isFullFledged(TokenInterface $token = null): bool
5454
{
5555
if (null === $token) {
5656
return false;

src/Symfony/Component/Security/Core/Authentication/AuthenticationTrustResolverInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,20 @@ interface AuthenticationTrustResolverInterface
2828
*
2929
* @return bool
3030
*/
31-
public function isAnonymous(TokenInterface $token = null);
31+
public function isAnonymous(TokenInterface $token = null): bool;
3232

3333
/**
3434
* Resolves whether the passed token implementation is authenticated
3535
* using remember-me capabilities.
3636
*
3737
* @return bool
3838
*/
39-
public function isRememberMe(TokenInterface $token = null);
39+
public function isRememberMe(TokenInterface $token = null): bool;
4040

4141
/**
4242
* Resolves whether the passed token implementation is fully authenticated.
4343
*
4444
* @return bool
4545
*/
46-
public function isFullFledged(TokenInterface $token = null);
46+
public function isFullFledged(TokenInterface $token = null): bool;
4747
}

src/Symfony/Component/Security/Core/Authentication/Provider/AnonymousAuthenticationProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function __construct(string $secret)
4646
/**
4747
* {@inheritdoc}
4848
*/
49-
public function authenticate(TokenInterface $token)
49+
public function authenticate(TokenInterface $token): TokenInterface
5050
{
5151
if (!$this->supports($token)) {
5252
throw new AuthenticationException('The token is not supported by this authentication provider.');
@@ -62,7 +62,7 @@ public function authenticate(TokenInterface $token)
6262
/**
6363
* {@inheritdoc}
6464
*/
65-
public function supports(TokenInterface $token)
65+
public function supports(TokenInterface $token): bool
6666
{
6767
return $token instanceof AnonymousToken;
6868
}

src/Symfony/Component/Security/Core/Authentication/Provider/DaoAuthenticationProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ protected function checkAuthentication(UserInterface $user, UsernamePasswordToke
8787
/**
8888
* {@inheritdoc}
8989
*/
90-
protected function retrieveUser(string $userIdentifier, UsernamePasswordToken $token)
90+
protected function retrieveUser(string $userIdentifier, UsernamePasswordToken $token): UserInterface
9191
{
9292
$user = $token->getUser();
9393
if ($user instanceof UserInterface) {

src/Symfony/Component/Security/Core/Authentication/Provider/LdapBindAuthenticationProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function setQueryString(string $queryString)
6464
/**
6565
* {@inheritdoc}
6666
*/
67-
protected function retrieveUser(string $userIdentifier, UsernamePasswordToken $token)
67+
protected function retrieveUser(string $userIdentifier, UsernamePasswordToken $token): UserInterface
6868
{
6969
if (AuthenticationProviderInterface::USERNAME_NONE_PROVIDED === $userIdentifier) {
7070
throw new UserNotFoundException('User identifier can not be null.');

src/Symfony/Component/Security/Core/Authentication/Provider/PreAuthenticatedAuthenticationProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function __construct(UserProviderInterface $userProvider, UserCheckerInte
4848
/**
4949
* {@inheritdoc}
5050
*/
51-
public function authenticate(TokenInterface $token)
51+
public function authenticate(TokenInterface $token): TokenInterface
5252
{
5353
if (!$this->supports($token)) {
5454
throw new AuthenticationException('The token is not supported by this authentication provider.');
@@ -79,7 +79,7 @@ public function authenticate(TokenInterface $token)
7979
/**
8080
* {@inheritdoc}
8181
*/
82-
public function supports(TokenInterface $token)
82+
public function supports(TokenInterface $token): bool
8383
{
8484
return $token instanceof PreAuthenticatedToken && $this->providerKey === $token->getFirewallName();
8585
}

src/Symfony/Component/Security/Core/Authentication/Provider/RememberMeAuthenticationProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct(UserCheckerInterface $userChecker, string $secret, s
4444
/**
4545
* {@inheritdoc}
4646
*/
47-
public function authenticate(TokenInterface $token)
47+
public function authenticate(TokenInterface $token): TokenInterface
4848
{
4949
if (!$this->supports($token)) {
5050
throw new AuthenticationException('The token is not supported by this authentication provider.');
@@ -72,7 +72,7 @@ public function authenticate(TokenInterface $token)
7272
/**
7373
* {@inheritdoc}
7474
*/
75-
public function supports(TokenInterface $token)
75+
public function supports(TokenInterface $token): bool
7676
{
7777
return $token instanceof RememberMeToken && $token->getFirewallName() === $this->providerKey;
7878
}

src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function __construct(UserCheckerInterface $userChecker, string $providerK
5555
/**
5656
* {@inheritdoc}
5757
*/
58-
public function authenticate(TokenInterface $token)
58+
public function authenticate(TokenInterface $token): TokenInterface
5959
{
6060
if (!$this->supports($token)) {
6161
throw new AuthenticationException('The token is not supported by this authentication provider.');
@@ -107,7 +107,7 @@ public function authenticate(TokenInterface $token)
107107
/**
108108
* {@inheritdoc}
109109
*/
110-
public function supports(TokenInterface $token)
110+
public function supports(TokenInterface $token): bool
111111
{
112112
return $token instanceof UsernamePasswordToken && $this->providerKey === $token->getFirewallName();
113113
}
@@ -119,7 +119,7 @@ public function supports(TokenInterface $token)
119119
*
120120
* @throws AuthenticationException if the credentials could not be validated
121121
*/
122-
abstract protected function retrieveUser(string $username, UsernamePasswordToken $token);
122+
abstract protected function retrieveUser(string $username, UsernamePasswordToken $token): UserInterface;
123123

124124
/**
125125
* Does additional checks on the user and token (like validating the

src/Symfony/Component/Security/Core/Authentication/RememberMe/InMemoryTokenProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class InMemoryTokenProvider implements TokenProviderInterface
2525
/**
2626
* {@inheritdoc}
2727
*/
28-
public function loadTokenBySeries(string $series)
28+
public function loadTokenBySeries(string $series): PersistentTokenInterface
2929
{
3030
if (!isset($this->tokens[$series])) {
3131
throw new TokenNotFoundException('No token found.');

src/Symfony/Component/Security/Core/Authentication/RememberMe/PersistentTokenInterface.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,28 @@ interface PersistentTokenInterface
2626
*
2727
* @return string
2828
*/
29-
public function getClass();
29+
public function getClass(): string;
3030

3131
/**
3232
* Returns the series.
3333
*
3434
* @return string
3535
*/
36-
public function getSeries();
36+
public function getSeries(): string;
3737

3838
/**
3939
* Returns the token value.
4040
*
4141
* @return string
4242
*/
43-
public function getTokenValue();
43+
public function getTokenValue(): string;
4444

4545
/**
4646
* Returns the time the token was last used.
4747
*
4848
* @return \DateTime
4949
*/
50-
public function getLastUsed();
50+
public function getLastUsed(): \DateTime;
5151

5252
/**
5353
* @return string

src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function getUserIdentifier(): string
8686
/**
8787
* {@inheritdoc}
8888
*/
89-
public function getUser()
89+
public function getUser(): string|\Stringable|UserInterface
9090
{
9191
return $this->user;
9292
}
@@ -128,7 +128,7 @@ public function setUser(string|\Stringable|UserInterface $user)
128128
*
129129
* @deprecated since Symfony 5.4
130130
*/
131-
public function isAuthenticated()
131+
public function isAuthenticated(): bool
132132
{
133133
if (1 > \func_num_args() || func_get_arg(0)) {
134134
trigger_deprecation('symfony/security-core', '5.4', 'Method "%s()" is deprecated. In version 6.0, security tokens won\'t have an "authenticated" flag anymore and will always be considered authenticated.', __METHOD__);
@@ -205,7 +205,7 @@ public function __unserialize(array $data): void
205205
*
206206
* @return array The token attributes
207207
*/
208-
public function getAttributes()
208+
public function getAttributes(): array
209209
{
210210
return $this->attributes;
211211
}
@@ -225,7 +225,7 @@ public function setAttributes(array $attributes)
225225
*
226226
* @return bool true if the attribute exists, false otherwise
227227
*/
228-
public function hasAttribute(string $name)
228+
public function hasAttribute(string $name): bool
229229
{
230230
return \array_key_exists($name, $this->attributes);
231231
}
@@ -237,7 +237,7 @@ public function hasAttribute(string $name)
237237
*
238238
* @throws \InvalidArgumentException When attribute doesn't exist for this token
239239
*/
240-
public function getAttribute(string $name)
240+
public function getAttribute(string $name): mixed
241241
{
242242
if (!\array_key_exists($name, $this->attributes)) {
243243
throw new \InvalidArgumentException(sprintf('This token has no "%s" attribute.', $name));

src/Symfony/Component/Security/Core/Authentication/Token/AnonymousToken.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __construct(string $secret, string|\Stringable|UserInterface $us
3939
/**
4040
* {@inheritdoc}
4141
*/
42-
public function getCredentials()
42+
public function getCredentials(): mixed
4343
{
4444
return '';
4545
}
@@ -49,7 +49,7 @@ public function getCredentials()
4949
*
5050
* @return string
5151
*/
52-
public function getSecret()
52+
public function getSecret(): string
5353
{
5454
return $this->secret;
5555
}

src/Symfony/Component/Security/Core/Authentication/Token/NullToken.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ public function getRoleNames(): array
2828
return [];
2929
}
3030

31-
public function getCredentials()
31+
public function getCredentials(): mixed
3232
{
3333
return '';
3434
}
3535

36-
public function getUser()
36+
public function getUser(): string|\Stringable|UserInterface
3737
{
3838
return '';
3939
}
@@ -58,7 +58,7 @@ public function getUserIdentifier(): string
5858
/**
5959
* @deprecated since Symfony 5.4
6060
*/
61-
public function isAuthenticated()
61+
public function isAuthenticated(): bool
6262
{
6363
if (0 === \func_num_args() || func_get_arg(0)) {
6464
trigger_deprecation('symfony/security-core', '5.4', 'Method "%s()" is deprecated. In version 6.0, security tokens won\'t have an "authenticated" flag anymore and will always be considered authenticated.', __METHOD__);
@@ -79,7 +79,7 @@ public function eraseCredentials()
7979
{
8080
}
8181

82-
public function getAttributes()
82+
public function getAttributes(): array
8383
{
8484
return [];
8585
}
@@ -89,12 +89,12 @@ public function setAttributes(array $attributes)
8989
throw new \BadMethodCallException('Cannot set attributes of NullToken.');
9090
}
9191

92-
public function hasAttribute(string $name)
92+
public function hasAttribute(string $name): bool
9393
{
9494
return false;
9595
}
9696

97-
public function getAttribute(string $name)
97+
public function getAttribute(string $name): mixed
9898
{
9999
return null;
100100
}

src/Symfony/Component/Security/Core/Authentication/Token/PreAuthenticatedToken.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function __construct(string|\Stringable|UserInterface $user, mixed $crede
5050
*
5151
* @deprecated since 5.2, use getFirewallName() instead
5252
*/
53-
public function getProviderKey()
53+
public function getProviderKey(): string
5454
{
5555
if (1 !== \func_num_args() || true !== func_get_arg(0)) {
5656
trigger_deprecation('symfony/security-core', '5.2', 'Method "%s" is deprecated, use "getFirewallName()" instead.', __METHOD__);
@@ -67,7 +67,7 @@ public function getFirewallName(): string
6767
/**
6868
* {@inheritdoc}
6969
*/
70-
public function getCredentials()
70+
public function getCredentials(): mixed
7171
{
7272
return $this->credentials;
7373
}

src/Symfony/Component/Security/Core/Authentication/Token/RememberMeToken.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function setAuthenticated(bool $authenticated)
6666
*
6767
* @deprecated since 5.2, use getFirewallName() instead
6868
*/
69-
public function getProviderKey()
69+
public function getProviderKey(): string
7070
{
7171
if (1 !== \func_num_args() || true !== func_get_arg(0)) {
7272
trigger_deprecation('symfony/security-core', '5.2', 'Method "%s" is deprecated, use "getFirewallName()" instead.', __METHOD__);
@@ -85,15 +85,15 @@ public function getFirewallName(): string
8585
*
8686
* @return string
8787
*/
88-
public function getSecret()
88+
public function getSecret(): string
8989
{
9090
return $this->secret;
9191
}
9292

9393
/**
9494
* {@inheritdoc}
9595
*/
96-
public function getCredentials()
96+
public function getCredentials(): mixed
9797
{
9898
return '';
9999
}

src/Symfony/Component/Security/Core/Authentication/Token/Storage/TokenStorage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class TokenStorage implements TokenStorageInterface, ResetInterface
3030
/**
3131
* {@inheritdoc}
3232
*/
33-
public function getToken()
33+
public function getToken(): ?TokenInterface
3434
{
3535
if ($initializer = $this->initializer) {
3636
$this->initializer = null;

src/Symfony/Component/Security/Core/Authentication/Token/Storage/TokenStorageInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ interface TokenStorageInterface
2525
*
2626
* @return TokenInterface|null
2727
*/
28-
public function getToken();
28+
public function getToken(): ?TokenInterface;
2929

3030
/**
3131
* Sets the authentication token.

0 commit comments

Comments
 (0)