Skip to content

Commit e267f60

Browse files
wouterjnicolas-grekas
authored andcommitted
[Components] Convert to native return types
1 parent d888d4a commit e267f60

22 files changed

+42
-151
lines changed

Authentication/RememberMe/InMemoryTokenProvider.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ public function loadTokenBySeries(string $series): PersistentTokenInterface
3131
return $this->tokens[$series];
3232
}
3333

34-
/**
35-
* @return void
36-
*/
37-
public function updateToken(string $series, #[\SensitiveParameter] string $tokenValue, \DateTime $lastUsed)
34+
public function updateToken(string $series, #[\SensitiveParameter] string $tokenValue, \DateTime $lastUsed): void
3835
{
3936
if (!isset($this->tokens[$series])) {
4037
throw new TokenNotFoundException('No token found.');
@@ -50,18 +47,12 @@ public function updateToken(string $series, #[\SensitiveParameter] string $token
5047
$this->tokens[$series] = $token;
5148
}
5249

53-
/**
54-
* @return void
55-
*/
56-
public function deleteTokenBySeries(string $series)
50+
public function deleteTokenBySeries(string $series): void
5751
{
5852
unset($this->tokens[$series]);
5953
}
6054

61-
/**
62-
* @return void
63-
*/
64-
public function createNewToken(PersistentTokenInterface $token)
55+
public function createNewToken(PersistentTokenInterface $token): void
6556
{
6657
$this->tokens[$token->getSeries()] = $token;
6758
}

Authentication/RememberMe/TokenProviderInterface.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,24 @@ interface TokenProviderInterface
2323
/**
2424
* Loads the active token for the given series.
2525
*
26-
* @return PersistentTokenInterface
27-
*
2826
* @throws TokenNotFoundException if the token is not found
2927
*/
30-
public function loadTokenBySeries(string $series);
28+
public function loadTokenBySeries(string $series): PersistentTokenInterface;
3129

3230
/**
3331
* Deletes all tokens belonging to series.
34-
*
35-
* @return void
3632
*/
37-
public function deleteTokenBySeries(string $series);
33+
public function deleteTokenBySeries(string $series): void;
3834

3935
/**
4036
* Updates the token according to this data.
4137
*
42-
* @return void
43-
*
4438
* @throws TokenNotFoundException if the token is not found
4539
*/
46-
public function updateToken(string $series, #[\SensitiveParameter] string $tokenValue, \DateTime $lastUsed);
40+
public function updateToken(string $series, #[\SensitiveParameter] string $tokenValue, \DateTime $lastUsed): void;
4741

4842
/**
4943
* Creates a new token.
50-
*
51-
* @return void
5244
*/
53-
public function createNewToken(PersistentTokenInterface $token);
45+
public function createNewToken(PersistentTokenInterface $token): void;
5446
}

Authentication/Token/AbstractToken.php

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,12 @@ public function getUser(): ?UserInterface
5353
return $this->user;
5454
}
5555

56-
/**
57-
* @return void
58-
*/
59-
public function setUser(UserInterface $user)
56+
public function setUser(UserInterface $user): void
6057
{
6158
$this->user = $user;
6259
}
6360

64-
/**
65-
* @return void
66-
*/
67-
public function eraseCredentials()
61+
public function eraseCredentials(): void
6862
{
6963
if ($this->getUser() instanceof UserInterface) {
7064
$this->getUser()->eraseCredentials();
@@ -118,10 +112,7 @@ public function getAttributes(): array
118112
return $this->attributes;
119113
}
120114

121-
/**
122-
* @return void
123-
*/
124-
public function setAttributes(array $attributes)
115+
public function setAttributes(array $attributes): void
125116
{
126117
$this->attributes = $attributes;
127118
}
@@ -140,10 +131,7 @@ public function getAttribute(string $name): mixed
140131
return $this->attributes[$name];
141132
}
142133

143-
/**
144-
* @return void
145-
*/
146-
public function setAttribute(string $name, mixed $value)
134+
public function setAttribute(string $name, mixed $value): void
147135
{
148136
$this->attributes[$name] = $value;
149137
}

Authentication/Token/NullToken.php

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ public function getUser(): ?UserInterface
3333
return null;
3434
}
3535

36-
/**
37-
* @return never
38-
*/
39-
public function setUser(UserInterface $user)
36+
public function setUser(UserInterface $user): never
4037
{
4138
throw new \BadMethodCallException('Cannot set user on a NullToken.');
4239
}
@@ -46,10 +43,7 @@ public function getUserIdentifier(): string
4643
return '';
4744
}
4845

49-
/**
50-
* @return void
51-
*/
52-
public function eraseCredentials()
46+
public function eraseCredentials(): void
5347
{
5448
}
5549

@@ -58,10 +52,7 @@ public function getAttributes(): array
5852
return [];
5953
}
6054

61-
/**
62-
* @return never
63-
*/
64-
public function setAttributes(array $attributes)
55+
public function setAttributes(array $attributes): never
6556
{
6657
throw new \BadMethodCallException('Cannot set attributes of NullToken.');
6758
}
@@ -76,10 +67,7 @@ public function getAttribute(string $name): mixed
7667
return null;
7768
}
7869

79-
/**
80-
* @return never
81-
*/
82-
public function setAttribute(string $name, mixed $value)
70+
public function setAttribute(string $name, mixed $value): never
8371
{
8472
throw new \BadMethodCallException('Cannot add attribute to NullToken.');
8573
}

Authentication/Token/Storage/TokenStorage.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ public function getToken(): ?TokenInterface
3737
return $this->token;
3838
}
3939

40-
/**
41-
* @return void
42-
*/
43-
public function setToken(?TokenInterface $token)
40+
public function setToken(?TokenInterface $token): void
4441
{
4542
if ($token) {
4643
// ensure any initializer is called
@@ -56,10 +53,7 @@ public function setInitializer(?callable $initializer): void
5653
$this->initializer = null === $initializer ? null : $initializer(...);
5754
}
5855

59-
/**
60-
* @return void
61-
*/
62-
public function reset()
56+
public function reset(): void
6357
{
6458
$this->setToken(null);
6559
}

Authentication/Token/Storage/TokenStorageInterface.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ public function getToken(): ?TokenInterface;
2929
* Sets the authentication token.
3030
*
3131
* @param TokenInterface|null $token A TokenInterface token, or null if no further authentication information should be stored
32-
*
33-
* @return void
3432
*/
35-
public function setToken(?TokenInterface $token);
33+
public function setToken(?TokenInterface $token): void;
3634
}

Authentication/Token/TokenInterface.php

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,21 @@ public function getUser(): ?UserInterface;
5050
/**
5151
* Sets the authenticated user in the token.
5252
*
53-
* @return void
54-
*
5553
* @throws \InvalidArgumentException
5654
*/
57-
public function setUser(UserInterface $user);
55+
public function setUser(UserInterface $user): void;
5856

5957
/**
6058
* Removes sensitive information from the token.
61-
*
62-
* @return void
6359
*/
64-
public function eraseCredentials();
60+
public function eraseCredentials(): void;
6561

6662
public function getAttributes(): array;
6763

6864
/**
6965
* @param array $attributes The token attributes
70-
*
71-
* @return void
7266
*/
73-
public function setAttributes(array $attributes);
67+
public function setAttributes(array $attributes): void;
7468

7569
public function hasAttribute(string $name): bool;
7670

@@ -79,10 +73,7 @@ public function hasAttribute(string $name): bool;
7973
*/
8074
public function getAttribute(string $name): mixed;
8175

82-
/**
83-
* @return void
84-
*/
85-
public function setAttribute(string $name, mixed $value);
76+
public function setAttribute(string $name, mixed $value): void;
8677

8778
/**
8879
* Returns all the necessary state of the object for serialization purposes.

Authorization/Voter/RoleHierarchyVoter.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ public function __construct(RoleHierarchyInterface $roleHierarchy, string $prefi
3131
parent::__construct($prefix);
3232
}
3333

34-
/**
35-
* @return array
36-
*/
37-
protected function extractRoles(TokenInterface $token)
34+
protected function extractRoles(TokenInterface $token): array
3835
{
3936
return $this->roleHierarchy->getReachableRoleNames($token->getRoleNames());
4037
}

Authorization/Voter/RoleVoter.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,7 @@ public function supportsType(string $subjectType): bool
5858
return true;
5959
}
6060

61-
/**
62-
* @return array
63-
*/
64-
protected function extractRoles(TokenInterface $token)
61+
protected function extractRoles(TokenInterface $token): array
6562
{
6663
return $token->getRoleNames();
6764
}

Event/AuthenticationEvent.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ public function __construct(TokenInterface $token)
2828
$this->authenticationToken = $token;
2929
}
3030

31-
/**
32-
* @return TokenInterface
33-
*/
34-
public function getAuthenticationToken()
31+
public function getAuthenticationToken(): TokenInterface
3532
{
3633
return $this->authenticationToken;
3734
}

0 commit comments

Comments
 (0)