From a0ffe6b50a906594d8fa951bb217ce6c2092ef0e Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 31 Dec 2024 14:42:03 +0100 Subject: [PATCH] fix issues reported by PHPStan --- phpstan.neon | 1 + .../CompilerPass/ResourceOwnerCompilerPass.php | 4 ++-- src/Security/Http/Firewall/RefreshAccessTokenListener.php | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 216329555..b88ecced5 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -19,3 +19,4 @@ parameters: - '#Parameter \$event of method HWI\\Bundle\\OAuthBundle\\Controller\\Connect\\AbstractController::dispatch\(\) has invalid type Symfony\\Component\\EventDispatcher\\Event.#' - '#Parameter \#2 \$array of function implode expects array, array given.#' - '#PHPDoc type DOMNode of property HWI\\Bundle\\OAuthBundle\\OAuth\\Response\\SensioConnectUserResponse::\$data is not covariant with PHPDoc type array of overridden property HWI\\Bundle\\OAuthBundle\\OAuth\\Response\\AbstractUserResponse::\$data#' + - '#Call to function method_exists\(\) with Symfony\\Component\\Security\\Http\\Authenticator\\Debug\\TraceableAuthenticator#' diff --git a/src/DependencyInjection/CompilerPass/ResourceOwnerCompilerPass.php b/src/DependencyInjection/CompilerPass/ResourceOwnerCompilerPass.php index bc822b972..eccab1184 100644 --- a/src/DependencyInjection/CompilerPass/ResourceOwnerCompilerPass.php +++ b/src/DependencyInjection/CompilerPass/ResourceOwnerCompilerPass.php @@ -67,11 +67,11 @@ private function registerResourceOwnerTypeClassParameters(ContainerBuilder $cont $resourceOwnerClass = $definition->getClass(); // Check whether a ResourceOwner class exists only if resource owner was set by its "options.type" - if (false === preg_match('~^%(?Phwi_oauth.resource_owner.(?P.+).class)%$~', $resourceOwnerClass, $match)) { + if (false === $result = preg_match('~^%(?Phwi_oauth.resource_owner.(?P.+).class)%$~', $resourceOwnerClass, $match)) { return; } - if (!($match['type'] ?? null)) { + if (0 === $result || !$match['type']) { continue; } diff --git a/src/Security/Http/Firewall/RefreshAccessTokenListener.php b/src/Security/Http/Firewall/RefreshAccessTokenListener.php index 2407f4b73..c9598d8db 100644 --- a/src/Security/Http/Firewall/RefreshAccessTokenListener.php +++ b/src/Security/Http/Firewall/RefreshAccessTokenListener.php @@ -40,7 +40,7 @@ protected function refreshToken(OAuthToken $token): OAuthToken return $this->authenticator->refreshToken($token); } - if ($this->authenticator instanceof TraceableAuthenticator) { + if ($this->authenticator instanceof TraceableAuthenticator && method_exists($this->authenticator, 'getAuthenticator')) { $authenticator = $this->authenticator->getAuthenticator(); if ($authenticator instanceof OAuthAuthenticator) {