Skip to content

Commit f3253d7

Browse files
Add return types to tests and final|internal|private methods
1 parent acc45b8 commit f3253d7

11 files changed

+29
-41
lines changed

Authorization/TraceableAccessDecisionManager.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,6 @@ public function addVoterVote(VoterInterface $voter, array $attributes, int $vote
8383
];
8484
}
8585

86-
/**
87-
* @return string
88-
*/
8986
public function getStrategy(): string
9087
{
9188
// The $strategy property is misleading because it stores the name of its
@@ -102,9 +99,6 @@ public function getVoters(): iterable
10299
return $this->voters;
103100
}
104101

105-
/**
106-
* @return array
107-
*/
108102
public function getDecisionLog(): array
109103
{
110104
return $this->decisionLog;

Encoder/MigratingPasswordEncoder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ public function __construct(PasswordEncoderInterface $bestEncoder, PasswordEncod
3434
/**
3535
* {@inheritdoc}
3636
*/
37-
public function encodePassword($raw, $salt)
37+
public function encodePassword($raw, $salt): string
3838
{
3939
return $this->bestEncoder->encodePassword($raw, $salt);
4040
}
4141

4242
/**
4343
* {@inheritdoc}
4444
*/
45-
public function isPasswordValid($encoded, $raw, $salt)
45+
public function isPasswordValid($encoded, $raw, $salt): bool
4646
{
4747
if ($this->bestEncoder->isPasswordValid($encoded, $raw, $salt)) {
4848
return true;

Encoder/NativePasswordEncoder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function encodePassword($raw, $salt): string
7878
/**
7979
* {@inheritdoc}
8080
*/
81-
public function isPasswordValid($encoded, $raw, $salt)
81+
public function isPasswordValid($encoded, $raw, $salt): bool
8282
{
8383
if (72 < \strlen($raw) && 0 === strpos($encoded, '$2')) {
8484
// BCrypt encodes only the first 72 chars

Encoder/SodiumPasswordEncoder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public static function isSupported(): bool
5454
/**
5555
* {@inheritdoc}
5656
*/
57-
public function encodePassword($raw, $salt)
57+
public function encodePassword($raw, $salt): string
5858
{
5959
if (\strlen($raw) > self::MAX_PASSWORD_LENGTH) {
6060
throw new BadCredentialsException('Invalid password.');
@@ -74,7 +74,7 @@ public function encodePassword($raw, $salt)
7474
/**
7575
* {@inheritdoc}
7676
*/
77-
public function isPasswordValid($encoded, $raw, $salt)
77+
public function isPasswordValid($encoded, $raw, $salt): bool
7878
{
7979
if (\strlen($raw) > self::MAX_PASSWORD_LENGTH) {
8080
return false;

Security.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ public function __construct(ContainerInterface $container)
3434
$this->container = $container;
3535
}
3636

37-
/**
38-
* @return UserInterface|null
39-
*/
40-
public function getUser()
37+
public function getUser(): ?UserInterface
4138
{
4239
if (!$token = $this->getToken()) {
4340
return null;

Tests/Authentication/AuthenticationTrustResolverTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,11 @@ public function unserialize($serialized)
164164
{
165165
}
166166

167-
public function __toString()
167+
public function __toString(): string
168168
{
169169
}
170170

171-
public function getRoles()
171+
public function getRoles(): array
172172
{
173173
}
174174

@@ -184,11 +184,11 @@ public function setUser($user)
184184
{
185185
}
186186

187-
public function getUsername()
187+
public function getUsername(): string
188188
{
189189
}
190190

191-
public function isAuthenticated()
191+
public function isAuthenticated(): bool
192192
{
193193
}
194194

@@ -200,15 +200,15 @@ public function eraseCredentials()
200200
{
201201
}
202202

203-
public function getAttributes()
203+
public function getAttributes(): array
204204
{
205205
}
206206

207207
public function setAttributes(array $attributes)
208208
{
209209
}
210210

211-
public function hasAttribute($name)
211+
public function hasAttribute($name): bool
212212
{
213213
}
214214

Tests/Authorization/Voter/VoterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ public function testVote(array $attributes, $expectedVote, $object, $message)
5959

6060
class VoterTest_Voter extends Voter
6161
{
62-
protected function voteOnAttribute($attribute, $object, TokenInterface $token)
62+
protected function voteOnAttribute($attribute, $object, TokenInterface $token): bool
6363
{
6464
return 'EDIT' === $attribute;
6565
}
6666

67-
protected function supports($attribute, $object)
67+
protected function supports($attribute, $object): bool
6868
{
6969
return $object instanceof \stdClass && \in_array($attribute, ['EDIT', 'CREATE']);
7070
}

Tests/Encoder/BasePasswordEncoderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616

1717
class PasswordEncoder extends BasePasswordEncoder
1818
{
19-
public function encodePassword($raw, $salt)
19+
public function encodePassword($raw, $salt): string
2020
{
2121
}
2222

23-
public function isPasswordValid($encoded, $raw, $salt)
23+
public function isPasswordValid($encoded, $raw, $salt): bool
2424
{
2525
}
2626
}

Tests/Encoder/EncoderFactoryTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,15 @@ public function getRoles()
139139
{
140140
}
141141

142-
public function getPassword()
142+
public function getPassword(): ?string
143143
{
144144
}
145145

146-
public function getSalt()
146+
public function getSalt(): ?string
147147
{
148148
}
149149

150-
public function getUsername()
150+
public function getUsername(): string
151151
{
152152
}
153153

@@ -164,7 +164,7 @@ class EncAwareUser extends SomeUser implements EncoderAwareInterface
164164
{
165165
public $encoderName = 'encoder_name';
166166

167-
public function getEncoderName()
167+
public function getEncoderName(): string
168168
{
169169
return $this->encoderName;
170170
}

Tests/User/InMemoryUserProviderTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ public function testRefresh()
4040
$this->assertFalse($refreshedUser->isCredentialsNonExpired());
4141
}
4242

43-
/**
44-
* @return InMemoryUserProvider
45-
*/
46-
protected function createProvider()
43+
protected function createProvider(): InMemoryUserProvider
4744
{
4845
return new InMemoryUserProvider([
4946
'fabien' => [

0 commit comments

Comments
 (0)