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 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 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..a4dcd17ce 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; @@ -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) { @@ -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;