Skip to content

Commit 9e4f261

Browse files
authored
Merge pull request #1454 from hafezdivandari/php84
Add PHP 8.4 support
2 parents 1dc1ee8 + 000ce9a commit 9e4f261

File tree

7 files changed

+17
-20
lines changed

7 files changed

+17
-20
lines changed

.github/workflows/static-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
php-version: [8.1, 8.2, 8.3]
15+
php-version: [8.1, 8.2, 8.3, 8.4]
1616
composer-stability: [prefer-lowest, prefer-stable]
1717
operating-system:
1818
- ubuntu-latest

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
php: [8.1, 8.2, 8.3]
14+
php: [8.1, 8.2, 8.3, 8.4]
1515
os: [ubuntu-22.04]
1616
stability: [prefer-lowest, prefer-stable]
1717

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"homepage": "https://oauth2.thephpleague.com/",
55
"license": "MIT",
66
"require": {
7-
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
7+
"php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0",
88
"ext-openssl": "*",
99
"league/event": "^3.0",
1010
"league/uri": "^7.0",
@@ -16,9 +16,9 @@
1616
"psr/http-server-middleware": "^1.0"
1717
},
1818
"require-dev": {
19-
"phpunit/phpunit": "^9.6.15",
20-
"laminas/laminas-diactoros": "^3.3.0",
21-
"phpstan/phpstan": "^1.10.55",
19+
"phpunit/phpunit": "^9.6.21",
20+
"laminas/laminas-diactoros": "^3.5",
21+
"phpstan/phpstan": "^1.12",
2222
"phpstan/phpstan-phpunit": "^1.3.15",
2323
"roave/security-advisories": "dev-master",
2424
"phpstan/extension-installer": "^1.3.1",

phpcs.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,5 @@
3333
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint" />
3434
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment" />
3535
<rule ref="SlevomatCodingStandard.Classes.RequireConstructorPropertyPromotion" />
36+
<rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue" />
3637
</ruleset>

src/Exception/OAuthServerException.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class OAuthServerException extends Exception
3333
/**
3434
* Throw a new exception.
3535
*/
36-
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)
36+
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)
3737
{
3838
parent::__construct($message, $code, $previous);
3939
$this->payload = [
@@ -88,7 +88,7 @@ public static function unsupportedGrantType(): static
8888
/**
8989
* Invalid request error.
9090
*/
91-
public static function invalidRequest(string $parameter, ?string $hint = null, Throwable $previous = null): static
91+
public static function invalidRequest(string $parameter, ?string $hint = null, ?Throwable $previous = null): static
9292
{
9393
$errorMessage = 'The request is missing a required parameter, includes an invalid parameter value, ' .
9494
'includes a parameter more than once, or is otherwise malformed.';
@@ -141,7 +141,7 @@ public static function invalidCredentials(): static
141141
*
142142
* @codeCoverageIgnore
143143
*/
144-
public static function serverError(string $hint, Throwable $previous = null): static
144+
public static function serverError(string $hint, ?Throwable $previous = null): static
145145
{
146146
return new static(
147147
'The authorization server encountered an unexpected condition which prevented it from fulfilling'
@@ -158,15 +158,15 @@ public static function serverError(string $hint, Throwable $previous = null): st
158158
/**
159159
* Invalid refresh token.
160160
*/
161-
public static function invalidRefreshToken(?string $hint = null, Throwable $previous = null): static
161+
public static function invalidRefreshToken(?string $hint = null, ?Throwable $previous = null): static
162162
{
163163
return new static('The refresh token is invalid.', 8, 'invalid_grant', 400, $hint, null, $previous);
164164
}
165165

166166
/**
167167
* Access denied.
168168
*/
169-
public static function accessDenied(?string $hint = null, ?string $redirectUri = null, Throwable $previous = null): static
169+
public static function accessDenied(?string $hint = null, ?string $redirectUri = null, ?Throwable $previous = null): static
170170
{
171171
return new static(
172172
'The resource owner or authorization server denied the request.',
@@ -207,15 +207,15 @@ public function getErrorType(): string
207207
*
208208
* @return static
209209
*/
210-
public static function expiredToken(?string $hint = null, Throwable $previous = null): static
210+
public static function expiredToken(?string $hint = null, ?Throwable $previous = null): static
211211
{
212212
$errorMessage = 'The `device_code` has expired and the device ' .
213213
'authorization session has concluded.';
214214

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

218-
public static function authorizationPending(string $hint = '', Throwable $previous = null): static
218+
public static function authorizationPending(string $hint = '', ?Throwable $previous = null): static
219219
{
220220
return new static(
221221
'The authorization request is still pending as the end user ' .
@@ -236,7 +236,7 @@ public static function authorizationPending(string $hint = '', Throwable $previo
236236
*
237237
* @return static
238238
*/
239-
public static function slowDown(string $hint = '', Throwable $previous = null): static
239+
public static function slowDown(string $hint = '', ?Throwable $previous = null): static
240240
{
241241
return new static(
242242
'The authorization request is still pending and polling should ' .

src/Grant/AbstractGrant.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ protected function validateRedirectUri(
243243
*
244244
* @return ScopeEntityInterface[]
245245
*/
246-
public function validateScopes(string|array|null $scopes, string $redirectUri = null): array
246+
public function validateScopes(string|array|null $scopes, ?string $redirectUri = null): array
247247
{
248248
if ($scopes === null) {
249249
$scopes = [];

src/ResourceServer.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,15 @@ class ResourceServer
2222
{
2323
private CryptKeyInterface $publicKey;
2424

25-
private ?AuthorizationValidatorInterface $authorizationValidator = null;
26-
2725
public function __construct(
2826
private AccessTokenRepositoryInterface $accessTokenRepository,
2927
CryptKeyInterface|string $publicKey,
30-
AuthorizationValidatorInterface $authorizationValidator = null
28+
private ?AuthorizationValidatorInterface $authorizationValidator = null
3129
) {
3230
if ($publicKey instanceof CryptKeyInterface === false) {
3331
$publicKey = new CryptKey($publicKey);
3432
}
3533
$this->publicKey = $publicKey;
36-
37-
$this->authorizationValidator = $authorizationValidator;
3834
}
3935

4036
protected function getAuthorizationValidator(): AuthorizationValidatorInterface

0 commit comments

Comments
 (0)