From b806c9bbe1d2836067ac0b5a94c19cacac2d4a5e 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 --- .github/workflows/ci.yaml | 4 ---- phpstan.neon | 1 + .../CompilerPass/ResourceOwnerCompilerPass.php | 4 ++-- src/Security/Http/Firewall/RefreshAccessTokenListener.php | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 35b10cdd7..4db3588c7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -2,10 +2,6 @@ name: CI on: push: - branches: - - master - paths-ignore: - - '**.md' pull_request: paths: - '.github/workflows/**' 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) {