Skip to content

Commit eda3305

Browse files
[Security] add return types
1 parent 2ac7230 commit eda3305

File tree

51 files changed

+67
-130
lines changed

Some content is hidden

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

51 files changed

+67
-130
lines changed

Authentication/AuthenticationTrustResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ public function isAuthenticated(TokenInterface $token = null): bool
2929
/**
3030
* {@inheritdoc}
3131
*/
32-
public function isRememberMe(TokenInterface $token = null)
32+
public function isRememberMe(TokenInterface $token = null): bool
3333
{
3434
return $token && $token instanceof RememberMeToken;
3535
}
3636

3737
/**
3838
* {@inheritdoc}
3939
*/
40-
public function isFullFledged(TokenInterface $token = null)
40+
public function isFullFledged(TokenInterface $token = null): bool
4141
{
4242
return $this->isAuthenticated($token) && !$this->isRememberMe($token);
4343
}

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.');

Authentication/RememberMe/PersistentTokenInterface.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,31 +21,23 @@ interface PersistentTokenInterface
2121
{
2222
/**
2323
* Returns the class of the user.
24-
*
25-
* @return string
2624
*/
27-
public function getClass();
25+
public function getClass(): string;
2826

2927
/**
3028
* Returns the series.
31-
*
32-
* @return string
3329
*/
34-
public function getSeries();
30+
public function getSeries(): string;
3531

3632
/**
3733
* Returns the token value.
38-
*
39-
* @return string
4034
*/
41-
public function getTokenValue();
35+
public function getTokenValue(): string;
4236

4337
/**
4438
* Returns the time the token was last used.
45-
*
46-
* @return \DateTime
4739
*/
48-
public function getLastUsed();
40+
public function getLastUsed(): \DateTime;
4941

5042
/**
5143
* Returns the identifier used to authenticate (e.g. their email address or username).

Authentication/Token/AbstractToken.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111

1212
namespace Symfony\Component\Security\Core\Authentication\Token;
1313

14-
use Symfony\Component\Security\Core\User\EquatableInterface;
15-
use Symfony\Component\Security\Core\User\LegacyPasswordAuthenticatedUserInterface;
16-
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
1714
use Symfony\Component\Security\Core\User\UserInterface;
1815

1916
/**
@@ -56,7 +53,7 @@ public function getUserIdentifier(): string
5653
/**
5754
* {@inheritdoc}
5855
*/
59-
public function getUser()
56+
public function getUser(): ?UserInterface
6057
{
6158
return $this->user;
6259
}
@@ -123,7 +120,7 @@ public function __unserialize(array $data): void
123120
/**
124121
* {@inheritdoc}
125122
*/
126-
public function getAttributes()
123+
public function getAttributes(): array
127124
{
128125
return $this->attributes;
129126
}
@@ -139,15 +136,15 @@ public function setAttributes(array $attributes)
139136
/**
140137
* {@inheritdoc}
141138
*/
142-
public function hasAttribute(string $name)
139+
public function hasAttribute(string $name): bool
143140
{
144141
return \array_key_exists($name, $this->attributes);
145142
}
146143

147144
/**
148145
* {@inheritdoc}
149146
*/
150-
public function getAttribute(string $name)
147+
public function getAttribute(string $name): mixed
151148
{
152149
if (!\array_key_exists($name, $this->attributes)) {
153150
throw new \InvalidArgumentException(sprintf('This token has no "%s" attribute.', $name));

Authentication/Token/NullToken.php

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

31-
public function getUser()
31+
public function getUser(): ?UserInterface
3232
{
3333
return null;
3434
}
@@ -47,7 +47,7 @@ public function eraseCredentials()
4747
{
4848
}
4949

50-
public function getAttributes()
50+
public function getAttributes(): array
5151
{
5252
return [];
5353
}
@@ -57,12 +57,12 @@ public function setAttributes(array $attributes)
5757
throw new \BadMethodCallException('Cannot set attributes of NullToken.');
5858
}
5959

60-
public function hasAttribute(string $name)
60+
public function hasAttribute(string $name): bool
6161
{
6262
return false;
6363
}
6464

65-
public function getAttribute(string $name)
65+
public function getAttribute(string $name): mixed
6666
{
6767
return null;
6868
}

Authentication/Token/RememberMeToken.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,7 @@ public function getFirewallName(): string
5151
return $this->firewallName;
5252
}
5353

54-
/**
55-
* @return string
56-
*/
57-
public function getSecret()
54+
public function getSecret(): string
5855
{
5956
return $this->secret;
6057
}

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;

Authentication/Token/Storage/TokenStorageInterface.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ interface TokenStorageInterface
2222
{
2323
/**
2424
* Returns the current security token.
25-
*
26-
* @return TokenInterface|null
2725
*/
28-
public function getToken();
26+
public function getToken(): ?TokenInterface;
2927

3028
/**
3129
* Sets the authentication token.

Authentication/Token/TokenInterface.php

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,9 @@ public function getRoleNames(): array;
4040
/**
4141
* Returns a user representation.
4242
*
43-
* @return UserInterface|null
44-
*
4543
* @see AbstractToken::setUser()
4644
*/
47-
public function getUser();
45+
public function getUser(): ?UserInterface;
4846

4947
/**
5048
* Sets the authenticated user in the token.
@@ -58,27 +56,19 @@ public function setUser(UserInterface $user);
5856
*/
5957
public function eraseCredentials();
6058

61-
/**
62-
* @return array
63-
*/
64-
public function getAttributes();
59+
public function getAttributes(): array;
6560

6661
/**
6762
* @param array $attributes The token attributes
6863
*/
6964
public function setAttributes(array $attributes);
7065

71-
/**
72-
* @return bool
73-
*/
74-
public function hasAttribute(string $name);
66+
public function hasAttribute(string $name): bool;
7567

7668
/**
77-
* @return mixed
78-
*
7969
* @throws \InvalidArgumentException When attribute doesn't exist for this token
8070
*/
81-
public function getAttribute(string $name);
71+
public function getAttribute(string $name): mixed;
8272

8373
public function setAttribute(string $name, mixed $value);
8474

AuthenticationEvents.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Component\Security\Core;
1313

14-
use Symfony\Component\Security\Core\Event\AuthenticationFailureEvent;
1514
use Symfony\Component\Security\Core\Event\AuthenticationSuccessEvent;
1615

1716
final class AuthenticationEvents

0 commit comments

Comments
 (0)