From ed194715515a87d0f9c80b8696baf37ae18beb81 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 23 Jan 2024 14:51:25 +0100 Subject: [PATCH] Apply php-cs-fixer fix --rules nullable_type_declaration_for_default_null_value --- DataCollector/SecurityDataCollector.php | 4 ++-- DependencyInjection/SecurityExtension.php | 4 ++-- LoginLink/FirewallAwareLoginLinkHandler.php | 2 +- Security/FirewallConfig.php | 2 +- Security/FirewallContext.php | 2 +- Tests/DataCollector/SecurityDataCollectorTest.php | 4 ++-- .../Compiler/RegisterEntryPointsPassTest.php | 2 +- .../Bundle/AnonymousBundle/AppCustomAuthenticator.php | 2 +- .../FirewallEntryPointBundle/Security/EntryPointStub.php | 2 +- .../Bundle/FormLoginBundle/Controller/LoginController.php | 2 +- .../Bundle/GuardedBundle/AppCustomAuthenticator.php | 2 +- .../Bundle/GuardedBundle/AuthenticationController.php | 2 +- 12 files changed, 15 insertions(+), 15 deletions(-) diff --git a/DataCollector/SecurityDataCollector.php b/DataCollector/SecurityDataCollector.php index 1ed51292..01eea81a 100644 --- a/DataCollector/SecurityDataCollector.php +++ b/DataCollector/SecurityDataCollector.php @@ -46,7 +46,7 @@ class SecurityDataCollector extends DataCollector implements LateDataCollectorIn private $hasVarDumper; private $authenticatorManagerEnabled; - public function __construct(TokenStorageInterface $tokenStorage = null, RoleHierarchyInterface $roleHierarchy = null, LogoutUrlGenerator $logoutUrlGenerator = null, AccessDecisionManagerInterface $accessDecisionManager = null, FirewallMapInterface $firewallMap = null, TraceableFirewallListener $firewall = null, bool $authenticatorManagerEnabled = false) + public function __construct(?TokenStorageInterface $tokenStorage = null, ?RoleHierarchyInterface $roleHierarchy = null, ?LogoutUrlGenerator $logoutUrlGenerator = null, ?AccessDecisionManagerInterface $accessDecisionManager = null, ?FirewallMapInterface $firewallMap = null, ?TraceableFirewallListener $firewall = null, bool $authenticatorManagerEnabled = false) { if (!$authenticatorManagerEnabled) { trigger_deprecation('symfony/security-bundle', '5.4', 'Setting the $authenticatorManagerEnabled argument of "%s" to "false" is deprecated, use the new authenticator system instead.', __METHOD__); @@ -65,7 +65,7 @@ public function __construct(TokenStorageInterface $tokenStorage = null, RoleHier /** * {@inheritdoc} */ - public function collect(Request $request, Response $response, \Throwable $exception = null) + public function collect(Request $request, Response $response, ?\Throwable $exception = null) { if (null === $this->tokenStorage) { $this->data = [ diff --git a/DependencyInjection/SecurityExtension.php b/DependencyInjection/SecurityExtension.php index c19cae04..41740edf 100644 --- a/DependencyInjection/SecurityExtension.php +++ b/DependencyInjection/SecurityExtension.php @@ -620,7 +620,7 @@ private function createContextListener(ContainerBuilder $container, string $cont return $this->contextListeners[$contextKey] = $listenerId; } - private function createAuthenticationListeners(ContainerBuilder $container, string $id, array $firewall, array &$authenticationProviders, ?string $defaultProvider, array $providerIds, ?string $defaultEntryPoint, string $contextListenerId = null) + private function createAuthenticationListeners(ContainerBuilder $container, string $id, array $firewall, array &$authenticationProviders, ?string $defaultProvider, array $providerIds, ?string $defaultEntryPoint, ?string $contextListenerId = null) { $listeners = []; $hasListeners = false; @@ -1060,7 +1060,7 @@ private function createExpression(ContainerBuilder $container, string $expressio return $this->expressions[$id] = new Reference($id); } - private function createRequestMatcher(ContainerBuilder $container, string $path = null, string $host = null, int $port = null, array $methods = [], array $ips = null, array $attributes = []): Reference + private function createRequestMatcher(ContainerBuilder $container, ?string $path = null, ?string $host = null, ?int $port = null, array $methods = [], ?array $ips = null, array $attributes = []): Reference { if ($methods) { $methods = array_map('strtoupper', $methods); diff --git a/LoginLink/FirewallAwareLoginLinkHandler.php b/LoginLink/FirewallAwareLoginLinkHandler.php index 5c61cfcf..ec9e658c 100644 --- a/LoginLink/FirewallAwareLoginLinkHandler.php +++ b/LoginLink/FirewallAwareLoginLinkHandler.php @@ -38,7 +38,7 @@ public function __construct(FirewallMap $firewallMap, ContainerInterface $loginL $this->requestStack = $requestStack; } - public function createLoginLink(UserInterface $user, Request $request = null): LoginLinkDetails + public function createLoginLink(UserInterface $user, ?Request $request = null): LoginLinkDetails { return $this->getForFirewall()->createLoginLink($user, $request); } diff --git a/Security/FirewallConfig.php b/Security/FirewallConfig.php index 4b361ffd..92953024 100644 --- a/Security/FirewallConfig.php +++ b/Security/FirewallConfig.php @@ -29,7 +29,7 @@ final class FirewallConfig private $authenticators; private $switchUser; - public function __construct(string $name, string $userChecker, string $requestMatcher = null, bool $securityEnabled = true, bool $stateless = false, string $provider = null, string $context = null, string $entryPoint = null, string $accessDeniedHandler = null, string $accessDeniedUrl = null, array $authenticators = [], array $switchUser = null) + public function __construct(string $name, string $userChecker, ?string $requestMatcher = null, bool $securityEnabled = true, bool $stateless = false, ?string $provider = null, ?string $context = null, ?string $entryPoint = null, ?string $accessDeniedHandler = null, ?string $accessDeniedUrl = null, array $authenticators = [], ?array $switchUser = null) { $this->name = $name; $this->userChecker = $userChecker; diff --git a/Security/FirewallContext.php b/Security/FirewallContext.php index 4ebc9c7d..e7ed2d0b 100644 --- a/Security/FirewallContext.php +++ b/Security/FirewallContext.php @@ -30,7 +30,7 @@ class FirewallContext /** * @param iterable $listeners */ - public function __construct(iterable $listeners, ExceptionListener $exceptionListener = null, LogoutListener $logoutListener = null, FirewallConfig $config = null) + public function __construct(iterable $listeners, ?ExceptionListener $exceptionListener = null, ?LogoutListener $logoutListener = null, ?FirewallConfig $config = null) { $this->listeners = $listeners; $this->exceptionListener = $exceptionListener; diff --git a/Tests/DataCollector/SecurityDataCollectorTest.php b/Tests/DataCollector/SecurityDataCollectorTest.php index 126a9702..ae706830 100644 --- a/Tests/DataCollector/SecurityDataCollectorTest.php +++ b/Tests/DataCollector/SecurityDataCollectorTest.php @@ -230,7 +230,7 @@ public function testCollectCollectsDecisionLogWhenStrategyIsAffirmative() $voter2 = new DummyVoter(); $decoratedVoter1 = new TraceableVoter($voter1, new class() implements EventDispatcherInterface { - public function dispatch(object $event, string $eventName = null): object + public function dispatch(object $event, ?string $eventName = null): object { return new \stdClass(); } @@ -305,7 +305,7 @@ public function testCollectCollectsDecisionLogWhenStrategyIsUnanimous() $voter2 = new DummyVoter(); $decoratedVoter1 = new TraceableVoter($voter1, new class() implements EventDispatcherInterface { - public function dispatch(object $event, string $eventName = null): object + public function dispatch(object $event, ?string $eventName = null): object { return new \stdClass(); } diff --git a/Tests/DependencyInjection/Compiler/RegisterEntryPointsPassTest.php b/Tests/DependencyInjection/Compiler/RegisterEntryPointsPassTest.php index b10b8a81..d2fb3486 100644 --- a/Tests/DependencyInjection/Compiler/RegisterEntryPointsPassTest.php +++ b/Tests/DependencyInjection/Compiler/RegisterEntryPointsPassTest.php @@ -93,7 +93,7 @@ public function onAuthenticationFailure(Request $request, AuthenticationExceptio ], JsonResponse::HTTP_FORBIDDEN); } - public function start(Request $request, AuthenticationException $authException = null): Response + public function start(Request $request, ?AuthenticationException $authException = null): Response { } } diff --git a/Tests/Functional/Bundle/AnonymousBundle/AppCustomAuthenticator.php b/Tests/Functional/Bundle/AnonymousBundle/AppCustomAuthenticator.php index c1d38688..ff3ed7c2 100644 --- a/Tests/Functional/Bundle/AnonymousBundle/AppCustomAuthenticator.php +++ b/Tests/Functional/Bundle/AnonymousBundle/AppCustomAuthenticator.php @@ -46,7 +46,7 @@ public function onAuthenticationSuccess(Request $request, TokenInterface $token, { } - public function start(Request $request, AuthenticationException $authException = null): Response + public function start(Request $request, ?AuthenticationException $authException = null): Response { return new Response($authException->getMessage(), Response::HTTP_UNAUTHORIZED); } diff --git a/Tests/Functional/Bundle/FirewallEntryPointBundle/Security/EntryPointStub.php b/Tests/Functional/Bundle/FirewallEntryPointBundle/Security/EntryPointStub.php index 56552b99..16a75726 100644 --- a/Tests/Functional/Bundle/FirewallEntryPointBundle/Security/EntryPointStub.php +++ b/Tests/Functional/Bundle/FirewallEntryPointBundle/Security/EntryPointStub.php @@ -20,7 +20,7 @@ class EntryPointStub implements AuthenticationEntryPointInterface { public const RESPONSE_TEXT = '2be8e651259189d841a19eecdf37e771e2431741'; - public function start(Request $request, AuthenticationException $authException = null): Response + public function start(Request $request, ?AuthenticationException $authException = null): Response { return new Response(self::RESPONSE_TEXT); } diff --git a/Tests/Functional/Bundle/FormLoginBundle/Controller/LoginController.php b/Tests/Functional/Bundle/FormLoginBundle/Controller/LoginController.php index db6aacca..373a1622 100644 --- a/Tests/Functional/Bundle/FormLoginBundle/Controller/LoginController.php +++ b/Tests/Functional/Bundle/FormLoginBundle/Controller/LoginController.php @@ -29,7 +29,7 @@ public function __construct(ContainerInterface $container) $this->container = $container; } - public function loginAction(Request $request, UserInterface $user = null) + public function loginAction(Request $request, ?UserInterface $user = null) { // get the login error if there is one if ($request->attributes->has(Security::AUTHENTICATION_ERROR)) { diff --git a/Tests/Functional/Bundle/GuardedBundle/AppCustomAuthenticator.php b/Tests/Functional/Bundle/GuardedBundle/AppCustomAuthenticator.php index 43e439ec..91d65fc2 100644 --- a/Tests/Functional/Bundle/GuardedBundle/AppCustomAuthenticator.php +++ b/Tests/Functional/Bundle/GuardedBundle/AppCustomAuthenticator.php @@ -48,7 +48,7 @@ public function onAuthenticationSuccess(Request $request, TokenInterface $token, { } - public function start(Request $request, AuthenticationException $authException = null): Response + public function start(Request $request, ?AuthenticationException $authException = null): Response { return new Response($authException->getMessage(), Response::HTTP_UNAUTHORIZED); } diff --git a/Tests/Functional/Bundle/GuardedBundle/AuthenticationController.php b/Tests/Functional/Bundle/GuardedBundle/AuthenticationController.php index 21a2ea9e..97358846 100644 --- a/Tests/Functional/Bundle/GuardedBundle/AuthenticationController.php +++ b/Tests/Functional/Bundle/GuardedBundle/AuthenticationController.php @@ -27,7 +27,7 @@ public function manualLoginAction(GuardAuthenticatorHandler $guardAuthenticatorH return new Response('Logged in.'); } - public function profileAction(UserInterface $user = null) + public function profileAction(?UserInterface $user = null) { if (null === $user) { return new Response('Not logged in.');