Skip to content

Commit 8871327

Browse files
[Security] add return types
1 parent acbbd99 commit 8871327

File tree

94 files changed

+143
-286
lines changed

Some content is hidden

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

94 files changed

+143
-286
lines changed

src/Symfony/Bundle/SecurityBundle/CacheWarmer/ExpressionCacheWarmer.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ public function __construct(iterable $expressions, ExpressionLanguage $expressio
2929
$this->expressionLanguage = $expressionLanguage;
3030
}
3131

32-
public function isOptional()
32+
public function isOptional(): bool
3333
{
3434
return true;
3535
}
3636

3737
/**
3838
* @return string[]
3939
*/
40-
public function warmUp(string $cacheDir)
40+
public function warmUp(string $cacheDir): array
4141
{
4242
foreach ($this->expressions as $expression) {
4343
$this->expressionLanguage->parse($expression, ['token', 'user', 'object', 'subject', 'role_names', 'request', 'trust_resolver']);

src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php

+7-20
Original file line numberDiff line numberDiff line change
@@ -230,20 +230,16 @@ public function getUser(): string
230230

231231
/**
232232
* Gets the roles of the user.
233-
*
234-
* @return array|Data
235233
*/
236-
public function getRoles()
234+
public function getRoles(): array|Data
237235
{
238236
return $this->data['roles'];
239237
}
240238

241239
/**
242240
* Gets the inherited roles of the user.
243-
*
244-
* @return array|Data
245241
*/
246-
public function getInheritedRoles()
242+
public function getInheritedRoles(): array|Data
247243
{
248244
return $this->data['inherited_roles'];
249245
}
@@ -282,10 +278,8 @@ public function getImpersonationExitPath(): ?string
282278

283279
/**
284280
* Get the class name of the security token.
285-
*
286-
* @return string|Data|null
287281
*/
288-
public function getTokenClass()
282+
public function getTokenClass(): string|Data|null
289283
{
290284
return $this->data['token_class'];
291285
}
@@ -305,7 +299,7 @@ public function getLogoutUrl(): ?string
305299
*
306300
* @return string[]|Data
307301
*/
308-
public function getVoters()
302+
public function getVoters(): array|Data
309303
{
310304
return $this->data['voters'];
311305
}
@@ -317,28 +311,21 @@ public function getVoterStrategy(): string
317311

318312
/**
319313
* Returns the log of the security decisions made by the access decision manager.
320-
*
321-
* @return array|Data
322314
*/
323-
public function getAccessDecisionLog()
315+
public function getAccessDecisionLog(): array|Data
324316
{
325317
return $this->data['access_decision_log'];
326318
}
327319

328320
/**
329321
* Returns the configuration of the current firewall context.
330-
*
331-
* @return array|Data|null
332322
*/
333-
public function getFirewall()
323+
public function getFirewall(): array|Data|null
334324
{
335325
return $this->data['firewall'];
336326
}
337327

338-
/**
339-
* @return array|Data
340-
*/
341-
public function getListeners()
328+
public function getListeners(): array|Data
342329
{
343330
return $this->data['listeners'];
344331
}

src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,8 @@ public function __construct(array $factories, array $userProviderFactories)
4242

4343
/**
4444
* Generates the configuration tree builder.
45-
*
46-
* @return TreeBuilder
4745
*/
48-
public function getConfigTreeBuilder()
46+
public function getConfigTreeBuilder(): TreeBuilder
4947
{
5048
$tb = new TreeBuilder('security');
5149
$rootNode = $tb->getRootNode();

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ abstract class AbstractFactory implements AuthenticatorFactoryInterface
4848
'failure_path_parameter' => '_failure_path',
4949
];
5050

51-
final public function addOption(string $name, mixed $default = null)
51+
final public function addOption(string $name, mixed $default = null): void
5252
{
5353
$this->options[$name] = $default;
5454
}

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AuthenticatorFactoryInterface.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@ public function getPriority(): int;
2727
/**
2828
* Defines the configuration key used to reference the provider
2929
* in the firewall configuration.
30-
*
31-
* @return string
3230
*/
33-
public function getKey();
31+
public function getKey(): string;
3432

3533
public function addConfiguration(NodeDefinition $builder);
3634

src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AuthenticatorFactoryInterface;
1616
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\FirewallListenerFactoryInterface;
1717
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvider\UserProviderFactoryInterface;
18+
use Symfony\Component\Config\Definition\ConfigurationInterface;
1819
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
1920
use Symfony\Component\Config\FileLocator;
2021
use Symfony\Component\Console\Application;
@@ -847,17 +848,17 @@ public function addUserProviderFactory(UserProviderFactoryInterface $factory)
847848
/**
848849
* {@inheritdoc}
849850
*/
850-
public function getXsdValidationBasePath()
851+
public function getXsdValidationBasePath(): string|false
851852
{
852853
return __DIR__.'/../Resources/config/schema';
853854
}
854855

855-
public function getNamespace()
856+
public function getNamespace(): string
856857
{
857858
return 'http://symfony.com/schema/dic/security';
858859
}
859860

860-
public function getConfiguration(array $config, ContainerBuilder $container)
861+
public function getConfiguration(array $config, ContainerBuilder $container): ?ConfigurationInterface
861862
{
862863
// first assemble the factories
863864
return new MainConfiguration($this->getSortedFactories(), $this->userProviderFactories);

src/Symfony/Bundle/SecurityBundle/EventListener/FirewallListener.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function onKernelFinishRequest(FinishRequestEvent $event)
5959
/**
6060
* {@inheritdoc}
6161
*/
62-
public static function getSubscribedEvents()
62+
public static function getSubscribedEvents(): array
6363
{
6464
return [
6565
KernelEvents::REQUEST => [

src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct(ContainerInterface $container, iterable $map)
3333
$this->map = $map;
3434
}
3535

36-
public function getListeners(Request $request)
36+
public function getListeners(Request $request): array
3737
{
3838
$context = $this->getFirewallContext($request);
3939

@@ -44,10 +44,7 @@ public function getListeners(Request $request)
4444
return [$context->getListeners(), $context->getExceptionListener(), $context->getLogoutListener()];
4545
}
4646

47-
/**
48-
* @return FirewallConfig|null
49-
*/
50-
public function getFirewallConfig(Request $request)
47+
public function getFirewallConfig(Request $request): ?FirewallConfig
5148
{
5249
$context = $this->getFirewallContext($request);
5350

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

+2-2
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
}

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

+1-1
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

+4-12
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).

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

+4-7
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));

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

+4-4
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
}

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

+1-4
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
}

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

+1-1
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

+1-3
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.

0 commit comments

Comments
 (0)