From ea8e4164aa4a369ce5a1391d503d188407cc7b75 Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Fri, 9 Feb 2024 17:09:07 +0100 Subject: [PATCH] Run cs-fixer against codebase --- src/Controller/Connect/AbstractController.php | 2 +- src/OAuth/Exception/HttpTransportException.php | 2 +- src/OAuth/ResourceOwner/AbstractResourceOwner.php | 2 +- src/OAuth/ResourceOwner/QQResourceOwner.php | 4 ++-- src/OAuth/ResourceOwner/SinaWeiboResourceOwner.php | 2 +- src/OAuth/ResourceOwner/SpotifyResourceOwner.php | 2 +- src/OAuth/ResourceOwnerInterface.php | 2 +- src/OAuth/State/State.php | 2 +- src/Security/Core/User/EntityUserProvider.php | 2 +- src/Security/Http/Authenticator/OAuthAuthenticator.php | 4 ++-- src/Security/Http/EntryPoint/OAuthEntryPoint.php | 2 +- src/Security/OAuthUtils.php | 4 ++-- .../ResourceOwner/GenericOAuth2ResourceOwnerTestCase.php | 2 +- src/Test/OAuth/ResourceOwner/ResourceOwnerTestCase.php | 2 +- src/Twig/Extension/OAuthRuntime.php | 2 +- tests/Fixtures/CustomResourceOwner.php | 2 +- 16 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/Controller/Connect/AbstractController.php b/src/Controller/Connect/AbstractController.php index 445805915..0d4ef1528 100644 --- a/src/Controller/Connect/AbstractController.php +++ b/src/Controller/Connect/AbstractController.php @@ -168,7 +168,7 @@ protected function getConfirmationResponse(Request $request, array $accessToken, /** * @param Event|DeprecatedEvent $event */ - protected function dispatch($event, string $eventName = null): void + protected function dispatch($event, ?string $eventName = null): void { $this->dispatcher->dispatch($event, $eventName); } diff --git a/src/OAuth/Exception/HttpTransportException.php b/src/OAuth/Exception/HttpTransportException.php index a0ae759a1..b80348dc7 100644 --- a/src/OAuth/Exception/HttpTransportException.php +++ b/src/OAuth/Exception/HttpTransportException.php @@ -17,7 +17,7 @@ final class HttpTransportException extends AuthenticationException { private string $ownerName; - public function __construct(string $message, string $ownerName, int $code = 0, \Throwable $previous = null) + public function __construct(string $message, string $ownerName, int $code = 0, ?\Throwable $previous = null) { parent::__construct($message, $code, $previous); $this->ownerName = $ownerName; diff --git a/src/OAuth/ResourceOwner/AbstractResourceOwner.php b/src/OAuth/ResourceOwner/AbstractResourceOwner.php index 3f58a17cd..8c085bac1 100644 --- a/src/OAuth/ResourceOwner/AbstractResourceOwner.php +++ b/src/OAuth/ResourceOwner/AbstractResourceOwner.php @@ -161,7 +161,7 @@ public function addStateParameter(string $key, string $value): void /** * {@inheritdoc} */ - public function storeState(StateInterface $state = null): void + public function storeState(?StateInterface $state = null): void { if (null === $state || 0 === \count($state->getAll())) { return; diff --git a/src/OAuth/ResourceOwner/QQResourceOwner.php b/src/OAuth/ResourceOwner/QQResourceOwner.php index f870b2cf3..3278e5cf7 100644 --- a/src/OAuth/ResourceOwner/QQResourceOwner.php +++ b/src/OAuth/ResourceOwner/QQResourceOwner.php @@ -46,7 +46,7 @@ public function getResponseContent(ResponseInterface $rawResponse): array /** * {@inheritdoc} */ - public function getUserInformation(array $accessToken = null, array $extraParameters = []) + public function getUserInformation(?array $accessToken = null, array $extraParameters = []) { $openid = $extraParameters['openid'] ?? $this->requestUserIdentifier($accessToken); @@ -90,7 +90,7 @@ protected function configureOptions(OptionsResolver $resolver) ]); } - private function requestUserIdentifier(array $accessToken = null) + private function requestUserIdentifier(?array $accessToken = null) { $url = $this->normalizeUrl($this->options['me_url'], [ 'access_token' => $accessToken['access_token'], diff --git a/src/OAuth/ResourceOwner/SinaWeiboResourceOwner.php b/src/OAuth/ResourceOwner/SinaWeiboResourceOwner.php index c6c32a6eb..8739dc9ec 100644 --- a/src/OAuth/ResourceOwner/SinaWeiboResourceOwner.php +++ b/src/OAuth/ResourceOwner/SinaWeiboResourceOwner.php @@ -34,7 +34,7 @@ final class SinaWeiboResourceOwner extends GenericOAuth2ResourceOwner /** * {@inheritdoc} */ - public function getUserInformation(array $accessToken = null, array $extraParameters = []) + public function getUserInformation(?array $accessToken = null, array $extraParameters = []) { $url = $this->normalizeUrl($this->options['infos_url'], [ 'access_token' => $accessToken['access_token'], diff --git a/src/OAuth/ResourceOwner/SpotifyResourceOwner.php b/src/OAuth/ResourceOwner/SpotifyResourceOwner.php index be6fe6082..8118633aa 100644 --- a/src/OAuth/ResourceOwner/SpotifyResourceOwner.php +++ b/src/OAuth/ResourceOwner/SpotifyResourceOwner.php @@ -38,7 +38,7 @@ final class SpotifyResourceOwner extends GenericOAuth2ResourceOwner /** * {@inheritdoc} */ - public function getUserInformation(array $accessToken = null, array $extraParameters = []) + public function getUserInformation(?array $accessToken = null, array $extraParameters = []) { $url = $this->normalizeUrl($this->options['infos_url'], [ 'access_token' => $accessToken['access_token'], diff --git a/src/OAuth/ResourceOwnerInterface.php b/src/OAuth/ResourceOwnerInterface.php index 064227dce..475dcd8f5 100644 --- a/src/OAuth/ResourceOwnerInterface.php +++ b/src/OAuth/ResourceOwnerInterface.php @@ -108,7 +108,7 @@ public function refreshAccessToken($refreshToken, array $extraParameters = []); public function getState(): StateInterface; - public function storeState(StateInterface $state = null); + public function storeState(?StateInterface $state = null); public function addStateParameter(string $key, string $value): void; } diff --git a/src/OAuth/State/State.php b/src/OAuth/State/State.php index 3ff0d76cf..fbd0db864 100644 --- a/src/OAuth/State/State.php +++ b/src/OAuth/State/State.php @@ -130,7 +130,7 @@ public function encode(): ?string * * @return array|null */ - private function parseStringParameter(string $queryParameter = null): ?array + private function parseStringParameter(?string $queryParameter = null): ?array { $urlDecoded = $queryParameter ? urldecode($queryParameter) : ''; diff --git a/src/Security/Core/User/EntityUserProvider.php b/src/Security/Core/User/EntityUserProvider.php index 07a902b19..74a90f6f8 100644 --- a/src/Security/Core/User/EntityUserProvider.php +++ b/src/Security/Core/User/EntityUserProvider.php @@ -44,7 +44,7 @@ final class EntityUserProvider implements UserProviderInterface, OAuthAwareUserP * @param string $class User entity class to load * @param array $properties Mapping of resource owners to properties */ - public function __construct(ManagerRegistry $registry, string $class, array $properties, string $managerName = null) + public function __construct(ManagerRegistry $registry, string $class, array $properties, ?string $managerName = null) { $this->em = $registry->getManager($managerName); $this->class = $class; diff --git a/src/Security/Http/Authenticator/OAuthAuthenticator.php b/src/Security/Http/Authenticator/OAuthAuthenticator.php index bbe85e615..1196496df 100644 --- a/src/Security/Http/Authenticator/OAuthAuthenticator.php +++ b/src/Security/Http/Authenticator/OAuthAuthenticator.php @@ -86,7 +86,7 @@ public function supports(Request $request): bool return false; } - public function start(Request $request, AuthenticationException $authException = null): Response + public function start(Request $request, ?AuthenticationException $authException = null): Response { if ($this->options['use_forward'] ?? false) { $subRequest = $this->httpUtils->createRequest($request, $this->options['login_path']); @@ -209,7 +209,7 @@ public function refreshToken(OAuthToken $token): OAuthToken * * @return T */ - public function recreateToken(OAuthToken $token, UserInterface $user = null): OAuthToken + public function recreateToken(OAuthToken $token, ?UserInterface $user = null): OAuthToken { $user = $user instanceof UserInterface ? $user : $token->getUser(); diff --git a/src/Security/Http/EntryPoint/OAuthEntryPoint.php b/src/Security/Http/EntryPoint/OAuthEntryPoint.php index ee41f9984..275e107bb 100644 --- a/src/Security/Http/EntryPoint/OAuthEntryPoint.php +++ b/src/Security/Http/EntryPoint/OAuthEntryPoint.php @@ -44,7 +44,7 @@ public function __construct(HttpKernelInterface $kernel, HttpUtils $httpUtils, s /** * {@inheritdoc} */ - public function start(Request $request, AuthenticationException $authException = null): Response + public function start(Request $request, ?AuthenticationException $authException = null): Response { if ($this->useForward) { $subRequest = $this->httpUtils->createRequest($request, $this->loginPath); diff --git a/src/Security/OAuthUtils.php b/src/Security/OAuthUtils.php index 3e5c0a26a..007358c37 100644 --- a/src/Security/OAuthUtils.php +++ b/src/Security/OAuthUtils.php @@ -74,7 +74,7 @@ public function getResourceOwners(): array return array_keys($resourceOwners); } - public function getAuthorizationUrl(Request $request, string $name, string $redirectUrl = null, array $extraParameters = []): string + public function getAuthorizationUrl(Request $request, string $name, ?string $redirectUrl = null, array $extraParameters = []): string { $resourceOwner = $this->getResourceOwner($name); @@ -252,7 +252,7 @@ private function getCurrentFirewallName(Request $request): ?string return null === $firewallConfig ? null : $firewallConfig->getName(); } - private function getResourceOwnerCheckPath(string $name, string $firewallName = null): ?string + private function getResourceOwnerCheckPath(string $name, ?string $firewallName = null): ?string { $resourceOwnerMaps = $this->ownerMaps; diff --git a/src/Test/OAuth/ResourceOwner/GenericOAuth2ResourceOwnerTestCase.php b/src/Test/OAuth/ResourceOwner/GenericOAuth2ResourceOwnerTestCase.php index fcb3d6f2b..cae1a4276 100644 --- a/src/Test/OAuth/ResourceOwner/GenericOAuth2ResourceOwnerTestCase.php +++ b/src/Test/OAuth/ResourceOwner/GenericOAuth2ResourceOwnerTestCase.php @@ -436,7 +436,7 @@ protected function createResourceOwner( array $options = [], array $paths = [], array $responses = [], - StateInterface $state = null + ?StateInterface $state = null ): GenericOAuth2ResourceOwner { /** @var GenericOAuth2ResourceOwner $resourceOwner */ $resourceOwner = parent::createResourceOwner($options, $paths, $responses); diff --git a/src/Test/OAuth/ResourceOwner/ResourceOwnerTestCase.php b/src/Test/OAuth/ResourceOwner/ResourceOwnerTestCase.php index 3bffd3880..a2b81827c 100644 --- a/src/Test/OAuth/ResourceOwner/ResourceOwnerTestCase.php +++ b/src/Test/OAuth/ResourceOwner/ResourceOwnerTestCase.php @@ -43,7 +43,7 @@ abstract class ResourceOwnerTestCase extends TestCase /** @var class-string */ protected string $resourceOwnerClass; - protected function createMockResponse(?string $response, string $contentType = null, int $httpCode = null): MockResponse + protected function createMockResponse(?string $response, ?string $contentType = null, ?int $httpCode = null): MockResponse { return new MockResponse( $response ?: '', diff --git a/src/Twig/Extension/OAuthRuntime.php b/src/Twig/Extension/OAuthRuntime.php index 9b631b257..93125a659 100644 --- a/src/Twig/Extension/OAuthRuntime.php +++ b/src/Twig/Extension/OAuthRuntime.php @@ -44,7 +44,7 @@ public function getLoginUrl(string $name): string return $this->oauthUtils->getLoginUrl($this->getMainRequest(), $name); } - public function getAuthorizationUrl(string $name, string $redirectUrl = null, array $extraParameters = []): string + public function getAuthorizationUrl(string $name, ?string $redirectUrl = null, array $extraParameters = []): string { return $this->oauthUtils->getAuthorizationUrl($this->getMainRequest(), $name, $redirectUrl, $extraParameters); } diff --git a/tests/Fixtures/CustomResourceOwner.php b/tests/Fixtures/CustomResourceOwner.php index 23576042f..f5bc70184 100644 --- a/tests/Fixtures/CustomResourceOwner.php +++ b/tests/Fixtures/CustomResourceOwner.php @@ -74,7 +74,7 @@ public function addStateParameter(string $key, string $value): void { } - public function storeState(StateInterface $state = null): void + public function storeState(?StateInterface $state = null): void { } }