Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PHP 8.4 support #1454

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

strategy:
matrix:
php-version: [8.1, 8.2, 8.3]
php-version: [8.1, 8.2, 8.3, 8.4]
composer-stability: [prefer-lowest, prefer-stable]
operating-system:
- ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [8.1, 8.2, 8.3]
php: [8.1, 8.2, 8.3, 8.4]
os: [ubuntu-22.04]
stability: [prefer-lowest, prefer-stable]

Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"homepage": "https://oauth2.thephpleague.com/",
"license": "MIT",
"require": {
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
"php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0",
"ext-openssl": "*",
"league/event": "^3.0",
"league/uri": "^7.0",
Expand All @@ -16,9 +16,9 @@
"psr/http-server-middleware": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^9.6.15",
"laminas/laminas-diactoros": "^3.3.0",
"phpstan/phpstan": "^1.10.55",
"phpunit/phpunit": "^9.6.21",
"laminas/laminas-diactoros": "^3.5",
"phpstan/phpstan": "^1.12",
"phpstan/phpstan-phpunit": "^1.3.15",
"roave/security-advisories": "dev-master",
"phpstan/extension-installer": "^1.3.1",
Expand Down
1 change: 1 addition & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint" />
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment" />
<rule ref="SlevomatCodingStandard.Classes.RequireConstructorPropertyPromotion" />
<rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue" />
</ruleset>
16 changes: 8 additions & 8 deletions src/Exception/OAuthServerException.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class OAuthServerException extends Exception
/**
* Throw a new exception.
*/
final public function __construct(string $message, int $code, private string $errorType, private int $httpStatusCode = 400, private ?string $hint = null, private ?string $redirectUri = null, Throwable $previous = null)
final public function __construct(string $message, int $code, private string $errorType, private int $httpStatusCode = 400, private ?string $hint = null, private ?string $redirectUri = null, ?Throwable $previous = null)
{
parent::__construct($message, $code, $previous);
$this->payload = [
Expand Down Expand Up @@ -88,7 +88,7 @@ public static function unsupportedGrantType(): static
/**
* Invalid request error.
*/
public static function invalidRequest(string $parameter, ?string $hint = null, Throwable $previous = null): static
public static function invalidRequest(string $parameter, ?string $hint = null, ?Throwable $previous = null): static
{
$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 @@ -141,7 +141,7 @@ public static function invalidCredentials(): static
*
* @codeCoverageIgnore
*/
public static function serverError(string $hint, Throwable $previous = null): static
public static function serverError(string $hint, ?Throwable $previous = null): static
{
return new static(
'The authorization server encountered an unexpected condition which prevented it from fulfilling'
Expand All @@ -158,15 +158,15 @@ public static function serverError(string $hint, Throwable $previous = null): st
/**
* Invalid refresh token.
*/
public static function invalidRefreshToken(?string $hint = null, Throwable $previous = null): static
public static function invalidRefreshToken(?string $hint = null, ?Throwable $previous = null): static
{
return new static('The refresh token is invalid.', 8, 'invalid_grant', 400, $hint, null, $previous);
}

/**
* Access denied.
*/
public static function accessDenied(?string $hint = null, ?string $redirectUri = null, Throwable $previous = null): static
public static function accessDenied(?string $hint = null, ?string $redirectUri = null, ?Throwable $previous = null): static
{
return new static(
'The resource owner or authorization server denied the request.',
Expand Down Expand Up @@ -207,15 +207,15 @@ public function getErrorType(): string
*
* @return static
*/
public static function expiredToken(?string $hint = null, Throwable $previous = null): static
public static function expiredToken(?string $hint = null, ?Throwable $previous = null): static
{
$errorMessage = 'The `device_code` has expired and the device ' .
'authorization session has concluded.';

return new static($errorMessage, 11, 'expired_token', 400, $hint, null, $previous);
}

public static function authorizationPending(string $hint = '', Throwable $previous = null): static
public static function authorizationPending(string $hint = '', ?Throwable $previous = null): static
{
return new static(
'The authorization request is still pending as the end user ' .
Expand All @@ -236,7 +236,7 @@ public static function authorizationPending(string $hint = '', Throwable $previo
*
* @return static
*/
public static function slowDown(string $hint = '', Throwable $previous = null): static
public static function slowDown(string $hint = '', ?Throwable $previous = null): static
{
return new static(
'The authorization request is still pending and polling should ' .
Expand Down
2 changes: 1 addition & 1 deletion src/Grant/AbstractGrant.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ protected function validateRedirectUri(
*
* @return ScopeEntityInterface[]
*/
public function validateScopes(string|array|null $scopes, string $redirectUri = null): array
public function validateScopes(string|array|null $scopes, ?string $redirectUri = null): array
{
if ($scopes === null) {
$scopes = [];
Expand Down
6 changes: 1 addition & 5 deletions src/ResourceServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,15 @@ class ResourceServer
{
private CryptKeyInterface $publicKey;

private ?AuthorizationValidatorInterface $authorizationValidator = null;

public function __construct(
private AccessTokenRepositoryInterface $accessTokenRepository,
CryptKeyInterface|string $publicKey,
AuthorizationValidatorInterface $authorizationValidator = null
private ?AuthorizationValidatorInterface $authorizationValidator = null
) {
if ($publicKey instanceof CryptKeyInterface === false) {
$publicKey = new CryptKey($publicKey);
}
$this->publicKey = $publicKey;

$this->authorizationValidator = $authorizationValidator;
}

protected function getAuthorizationValidator(): AuthorizationValidatorInterface
Expand Down