From 3e04d777cf355bbbc49faf7e57457bfb89d73054 Mon Sep 17 00:00:00 2001 From: Hlavtox Date: Wed, 20 Nov 2024 12:48:47 +0100 Subject: [PATCH 1/4] Fix PHP 8.4 deprecation notices --- src/AuthorizationServer.php | 4 ++-- src/AuthorizationValidators/BearerTokenValidator.php | 2 +- src/Exception/OAuthServerException.php | 10 +++++----- src/ResourceServer.php | 2 +- tests/Stubs/GrantType.php | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/AuthorizationServer.php b/src/AuthorizationServer.php index 4d6862157..5e6841f36 100644 --- a/src/AuthorizationServer.php +++ b/src/AuthorizationServer.php @@ -100,7 +100,7 @@ public function __construct( ScopeRepositoryInterface $scopeRepository, $privateKey, $encryptionKey, - ResponseTypeInterface $responseType = null + ?ResponseTypeInterface $responseType = null ) { $this->clientRepository = $clientRepository; $this->accessTokenRepository = $accessTokenRepository; @@ -128,7 +128,7 @@ public function __construct( * @param GrantTypeInterface $grantType * @param null|DateInterval $accessTokenTTL */ - public function enableGrantType(GrantTypeInterface $grantType, DateInterval $accessTokenTTL = null) + public function enableGrantType(GrantTypeInterface $grantType, ?DateInterval $accessTokenTTL = null) { if ($accessTokenTTL === null) { $accessTokenTTL = new DateInterval('PT1H'); diff --git a/src/AuthorizationValidators/BearerTokenValidator.php b/src/AuthorizationValidators/BearerTokenValidator.php index 7723eda81..ae99e0f38 100644 --- a/src/AuthorizationValidators/BearerTokenValidator.php +++ b/src/AuthorizationValidators/BearerTokenValidator.php @@ -52,7 +52,7 @@ class BearerTokenValidator implements AuthorizationValidatorInterface * @param AccessTokenRepositoryInterface $accessTokenRepository * @param \DateInterval|null $jwtValidAtDateLeeway */ - public function __construct(AccessTokenRepositoryInterface $accessTokenRepository, \DateInterval $jwtValidAtDateLeeway = null) + public function __construct(AccessTokenRepositoryInterface $accessTokenRepository, ?\DateInterval $jwtValidAtDateLeeway = null) { $this->accessTokenRepository = $accessTokenRepository; $this->jwtValidAtDateLeeway = $jwtValidAtDateLeeway; diff --git a/src/Exception/OAuthServerException.php b/src/Exception/OAuthServerException.php index a0be0a5dd..3d2fc8986 100644 --- a/src/Exception/OAuthServerException.php +++ b/src/Exception/OAuthServerException.php @@ -57,7 +57,7 @@ class OAuthServerException extends Exception * @param null|string $redirectUri A HTTP URI to redirect the user back to * @param Throwable $previous Previous exception */ - public function __construct($message, $code, $errorType, $httpStatusCode = 400, $hint = null, $redirectUri = null, Throwable $previous = null) + public function __construct($message, $code, $errorType, $httpStatusCode = 400, $hint = null, $redirectUri = null, ?Throwable $previous = null) { parent::__construct($message, $code, $previous); $this->httpStatusCode = $httpStatusCode; @@ -133,7 +133,7 @@ public static function unsupportedGrantType() * * @return static */ - public static function invalidRequest($parameter, $hint = null, Throwable $previous = null) + public static function invalidRequest($parameter, $hint = null, ?Throwable $previous = null) { $errorMessage = 'The request is missing a required parameter, includes an invalid parameter value, ' . 'includes a parameter more than once, or is otherwise malformed.'; @@ -202,7 +202,7 @@ public static function invalidCredentials() * * @codeCoverageIgnore */ - public static function serverError($hint, Throwable $previous = null) + public static function serverError($hint, ?Throwable $previous = null) { return new static( 'The authorization server encountered an unexpected condition which prevented it from fulfilling' @@ -224,7 +224,7 @@ public static function serverError($hint, Throwable $previous = null) * * @return static */ - public static function invalidRefreshToken($hint = null, Throwable $previous = null) + public static function invalidRefreshToken($hint = null, ?Throwable $previous = null) { return new static('The refresh token is invalid.', 8, 'invalid_request', 401, $hint, null, $previous); } @@ -238,7 +238,7 @@ public static function invalidRefreshToken($hint = null, Throwable $previous = n * * @return static */ - public static function accessDenied($hint = null, $redirectUri = null, Throwable $previous = null) + public static function accessDenied($hint = null, $redirectUri = null, ?Throwable $previous = null) { return new static( 'The resource owner or authorization server denied the request.', diff --git a/src/ResourceServer.php b/src/ResourceServer.php index e1f98d6d1..d20d80d51 100644 --- a/src/ResourceServer.php +++ b/src/ResourceServer.php @@ -42,7 +42,7 @@ class ResourceServer public function __construct( AccessTokenRepositoryInterface $accessTokenRepository, $publicKey, - AuthorizationValidatorInterface $authorizationValidator = null + ?AuthorizationValidatorInterface $authorizationValidator = null ) { $this->accessTokenRepository = $accessTokenRepository; diff --git a/tests/Stubs/GrantType.php b/tests/Stubs/GrantType.php index 5270a47a0..a65f576e4 100644 --- a/tests/Stubs/GrantType.php +++ b/tests/Stubs/GrantType.php @@ -19,7 +19,7 @@ final class GrantType implements GrantTypeInterface { private $emitter; - public function setEmitter(EmitterInterface $emitter = null) + public function setEmitter(?EmitterInterface $emitter = null) { $this->emitter = $emitter; From 955cd9864e08dfb10eb401a96ba101402e33acab Mon Sep 17 00:00:00 2001 From: Hlavtox Date: Wed, 20 Nov 2024 12:50:39 +0100 Subject: [PATCH 2/4] Fix code style --- src/Exception/OAuthServerException.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Exception/OAuthServerException.php b/src/Exception/OAuthServerException.php index 3d2fc8986..a4dcd17ce 100644 --- a/src/Exception/OAuthServerException.php +++ b/src/Exception/OAuthServerException.php @@ -65,7 +65,7 @@ public function __construct($message, $code, $errorType, $httpStatusCode = 400, $this->hint = $hint; $this->redirectUri = $redirectUri; $this->payload = [ - 'error' => $errorType, + 'error' => $errorType, 'error_description' => $message, ]; if ($hint !== null) { From 9899dba73934b84339ee3414873722a7b4bea2eb Mon Sep 17 00:00:00 2001 From: Hlavtox Date: Fri, 22 Nov 2024 10:36:19 +0100 Subject: [PATCH 3/4] Update code style CI configuration --- .styleci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.styleci.yml b/.styleci.yml index 1caa7b894..6c7698f92 100644 --- a/.styleci.yml +++ b/.styleci.yml @@ -27,6 +27,7 @@ enabled: - no_unreachable_default_argument_value - no_unused_imports - no_whitespace_before_comma_in_array + - nullable_type_declarations - ordered_imports - phpdoc_align - phpdoc_indent From 60954be7d9138bbb1c5ab917d6c730e4ba8c907a Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Tue, 10 Dec 2024 17:48:41 +0800 Subject: [PATCH 4/4] wip Signed-off-by: Mior Muhammad Zaki --- .github/workflows/tests.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1f1db9e1b..b971693af 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,7 +8,7 @@ on: jobs: tests: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 strategy: fail-fast: false @@ -20,7 +20,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -28,6 +28,10 @@ jobs: php-version: ${{ matrix.php }} extensions: dom, curl, libxml, mbstring, zip coverage: pcov + + - name: Remove Security Advisories on obsolete PHP versions + run: composer remove "roave/security-advisories" --dev --no-update + if: matrix.php <= 7.4 - name: Install dependencies run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress