Skip to content

Commit

Permalink
Merge pull request #1466 from crynobone/fix-php84-deprecations
Browse files Browse the repository at this point in the history
[8.4.x] Fix PHP 8.4 deprecation notices
  • Loading branch information
Sephster authored Dec 13, 2024
2 parents 007dc5f + 60954be commit d7471b7
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 13 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
tests:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04

strategy:
fail-fast: false
Expand All @@ -20,14 +20,18 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
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
Expand Down
1 change: 1 addition & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/AuthorizationServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function __construct(
ScopeRepositoryInterface $scopeRepository,
$privateKey,
$encryptionKey,
ResponseTypeInterface $responseType = null
?ResponseTypeInterface $responseType = null
) {
$this->clientRepository = $clientRepository;
$this->accessTokenRepository = $accessTokenRepository;
Expand Down Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/AuthorizationValidators/BearerTokenValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions src/Exception/OAuthServerException.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ 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;
$this->errorType = $errorType;
$this->hint = $hint;
$this->redirectUri = $redirectUri;
$this->payload = [
'error' => $errorType,
'error' => $errorType,
'error_description' => $message,
];
if ($hint !== null) {
Expand Down Expand Up @@ -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.';
Expand Down Expand Up @@ -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'
Expand All @@ -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);
}
Expand All @@ -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.',
Expand Down
2 changes: 1 addition & 1 deletion src/ResourceServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ResourceServer
public function __construct(
AccessTokenRepositoryInterface $accessTokenRepository,
$publicKey,
AuthorizationValidatorInterface $authorizationValidator = null
?AuthorizationValidatorInterface $authorizationValidator = null
) {
$this->accessTokenRepository = $accessTokenRepository;

Expand Down
2 changes: 1 addition & 1 deletion tests/Stubs/GrantType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit d7471b7

Please sign in to comment.