Skip to content

Commit 59c6f9a

Browse files
authored
Support PHP 8 (#60)
1 parent d7b9555 commit 59c6f9a

4 files changed

Lines changed: 12 additions & 9 deletions

File tree

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ jobs:
88
strategy:
99
fail-fast: true
1010
matrix:
11-
php: [7.4, 7.3, 7.2]
11+
php: [8.0, 7.4, 7.3, 7.2]
1212
stability: [prefer-lowest, prefer-stable]
1313

1414
name: PHP ${{ matrix.php }} - ${{ matrix.stability }}
15-
15+
1616
env:
1717
DHLPARCEL_ACCOUNT_ID: ${{ secrets.DHLPARCEL_ACCOUNT_ID }}
1818
DHLPARCEL_ID: ${{ secrets.DHLPARCEL_ID }}

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
}
1818
],
1919
"require": {
20-
"php": "^7.2",
20+
"php": "^7.2 || ^8.0",
2121
"ext-json": "*",
2222
"composer/ca-bundle": "^1.2",
2323
"guzzlehttp/guzzle": "^6.4 || ^7.1",
24-
"lcobucci/jwt": "^3.4",
24+
"lcobucci/jwt": "^3.4 || ^4.0",
2525
"ramsey/uuid": "^4.0",
2626
"tightenco/collect": "^5.8 || ^6.0 || ^7.0 || ^8.0"
2727
},

src/Resources/AccessToken.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Mvdnbrk\DhlParcel\Resources;
44

55
use DateTimeImmutable;
6-
use Lcobucci\JWT\Parser;
6+
use Lcobucci\JWT\Configuration;
77

88
class AccessToken
99
{
@@ -28,7 +28,7 @@ public function __construct(string $token)
2828

2929
private function parseToken(): void
3030
{
31-
$token = (new Parser)->parse($this->token);
31+
$token = Configuration::forUnsecuredSigner()->parser()->parse($this->token);
3232

3333
$this->expiresAt = $token->claims()->get('exp') ?: new DateTimeImmutable;
3434
$this->accounts = $token->claims()->get('accounts');

tests/Feature/Endpoints/AuthenticationTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
namespace Mvdnbrk\DhlParcel\Tests\Feature\Endpoints;
44

5-
use Lcobucci\JWT\Parser;
6-
use Lcobucci\JWT\ValidationData;
5+
use Lcobucci\JWT\Configuration;
76
use Mvdnbrk\DhlParcel\Tests\TestCase;
87

98
/** @group integration */
@@ -13,9 +12,13 @@ class AuthenticationTest extends TestCase
1312
public function it_can_retrieve_an_access_token()
1413
{
1514
$accessToken = $this->client->authentication->getAccessToken();
15+
$parsedToken = Configuration::forUnsecuredSigner()->parser()->parse($accessToken->token);
1616

1717
$this->assertTrue(
18-
(new Parser)->parse($accessToken->token)->validate(new ValidationData())
18+
Configuration::forUnsecuredSigner()->validator()->validate(
19+
$parsedToken,
20+
new \Lcobucci\JWT\Validation\Constraint\IdentifiedBy($parsedToken->claims()->get('jti'))
21+
)
1922
);
2023
$this->assertFalse($accessToken->isExpired());
2124
$this->assertEquals(getenv('DHLPARCEL_ACCOUNT_ID'), $accessToken->getAccountId());

0 commit comments

Comments
 (0)