Skip to content
This repository was archived by the owner on May 31, 2024. It is now read-only.

Commit 2dc4ace

Browse files
committed
minor #33709 Add types to constructors and private/final/internal methods (Batch II) (derrabus)
This PR was squashed before being merged into the 4.4 branch (closes #33709). Discussion ---------- Add types to constructors and private/final/internal methods (Batch II) | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | #32179, #33228 | License | MIT | Doc PR | N/A Followup to #33519, this time with: * Form * HttpClient * HttpKernel * intl * Ldap * Ldap * Lock * Messenger * Processor * PropertyInfo * Routing * Security * Serializer * Stopwatch * Translation Commits ------- 9378eb4858 Add types to constructors and private/final/internal methods (Batch II)
2 parents bf10280 + 54f6d45 commit 2dc4ace

File tree

10 files changed

+14
-14
lines changed

10 files changed

+14
-14
lines changed

Core/Authentication/Token/AbstractToken.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ public function __toString()
299299
return sprintf('%s(user="%s", authenticated=%s, roles="%s")', $class, $this->getUsername(), json_encode($this->authenticated), implode(', ', $roles));
300300
}
301301

302-
private function hasUserChanged(UserInterface $user)
302+
private function hasUserChanged(UserInterface $user): bool
303303
{
304304
if (!($this->user instanceof UserInterface)) {
305305
throw new \BadMethodCallException('Method "hasUserChanged" should be called when current user class is instance of "UserInterface".');

Core/Authorization/Voter/ExpressionVoter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function vote(TokenInterface $token, $subject, array $attributes)
9393
return $result;
9494
}
9595

96-
private function getVariables(TokenInterface $token, $subject)
96+
private function getVariables(TokenInterface $token, $subject): array
9797
{
9898
if (method_exists($token, 'getRoleNames')) {
9999
$roleNames = $token->getRoleNames();

Core/Encoder/Argon2iPasswordEncoder.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,12 @@ public function isPasswordValid($encoded, $raw, $salt)
102102
throw new \LogicException('Argon2i algorithm is not supported. Please install the libsodium extension or upgrade to PHP 7.2+.');
103103
}
104104

105-
private function encodePasswordNative(string $raw)
105+
private function encodePasswordNative(string $raw): string
106106
{
107107
return password_hash($raw, \PASSWORD_ARGON2I, $this->config);
108108
}
109109

110-
private function encodePasswordSodiumFunction(string $raw)
110+
private function encodePasswordSodiumFunction(string $raw): string
111111
{
112112
$hash = sodium_crypto_pwhash_str(
113113
$raw,
@@ -119,7 +119,7 @@ private function encodePasswordSodiumFunction(string $raw)
119119
return $hash;
120120
}
121121

122-
private function encodePasswordSodiumExtension(string $raw)
122+
private function encodePasswordSodiumExtension(string $raw): string
123123
{
124124
$hash = \Sodium\crypto_pwhash_str(
125125
$raw,

Core/Encoder/EncoderFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ private function createEncoder(array $config): PasswordEncoderInterface
8080
return $reflection->newInstanceArgs($config['arguments']);
8181
}
8282

83-
private function getEncoderConfigFromAlgorithm(array $config)
83+
private function getEncoderConfigFromAlgorithm(array $config): array
8484
{
8585
if ('auto' === $config['algorithm']) {
8686
$encoderChain = [];

Core/User/User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function __toString(): string
5353
/**
5454
* {@inheritdoc}
5555
*/
56-
public function getRoles()
56+
public function getRoles(): array
5757
{
5858
return $this->roles;
5959
}

Csrf/CsrfTokenManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function isTokenValid(CsrfToken $token)
114114
return hash_equals($this->storage->getToken($namespacedId), $token->getValue());
115115
}
116116

117-
private function getNamespace()
117+
private function getNamespace(): string
118118
{
119119
return \is_callable($ns = $this->namespace) ? $ns() : $ns;
120120
}

Csrf/Tests/CsrfTokenManagerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public function getManagerGeneratorAndStorage()
202202
return $data;
203203
}
204204

205-
private function getGeneratorAndStorage()
205+
private function getGeneratorAndStorage(): array
206206
{
207207
return [
208208
$this->getMockBuilder('Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface')->getMock(),

Guard/Provider/GuardAuthenticationProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function authenticate(TokenInterface $token)
9999
return $this->authenticateViaGuard($guardAuthenticator, $token);
100100
}
101101

102-
private function authenticateViaGuard(AuthenticatorInterface $guardAuthenticator, PreAuthenticationGuardToken $token)
102+
private function authenticateViaGuard(AuthenticatorInterface $guardAuthenticator, PreAuthenticationGuardToken $token): GuardTokenInterface
103103
{
104104
// get the user from the GuardAuthenticator
105105
$user = $guardAuthenticator->getUser($token->getCredentials(), $this->userProvider);
@@ -134,7 +134,7 @@ private function authenticateViaGuard(AuthenticatorInterface $guardAuthenticator
134134
return $authenticatedToken;
135135
}
136136

137-
private function findOriginatingAuthenticator(PreAuthenticationGuardToken $token)
137+
private function findOriginatingAuthenticator(PreAuthenticationGuardToken $token): ?AuthenticatorInterface
138138
{
139139
// find the *one* GuardAuthenticator that this token originated from
140140
foreach ($this->guardAuthenticators as $key => $guardAuthenticator) {

Http/Firewall/AbstractAuthenticationListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ protected function requiresAuthentication(Request $request)
171171
*/
172172
abstract protected function attemptAuthentication(Request $request);
173173

174-
private function onFailure(Request $request, AuthenticationException $failed)
174+
private function onFailure(Request $request, AuthenticationException $failed): Response
175175
{
176176
if (null !== $this->logger) {
177177
$this->logger->error('Authentication request failed.', ['exception' => $failed]);
@@ -191,7 +191,7 @@ private function onFailure(Request $request, AuthenticationException $failed)
191191
return $response;
192192
}
193193

194-
private function onSuccess(Request $request, TokenInterface $token)
194+
private function onSuccess(Request $request, TokenInterface $token): Response
195195
{
196196
if (null !== $this->logger) {
197197
$this->logger->info('User has been authenticated successfully.', ['username' => $token->getUsername()]);

Http/Firewall/UsernamePasswordJsonAuthenticationListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ private function onSuccess(Request $request, TokenInterface $token): ?Response
168168
return $response;
169169
}
170170

171-
private function onFailure(Request $request, AuthenticationException $failed)
171+
private function onFailure(Request $request, AuthenticationException $failed): Response
172172
{
173173
if (null !== $this->logger) {
174174
$this->logger->info('Authentication request failed.', ['exception' => $failed]);

0 commit comments

Comments
 (0)