diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 5e7e472c..702ce63b 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -9,8 +9,8 @@ jobs: strategy: fail-fast: false matrix: - php: ['7.4', '8.0', '8.1'] - symfony: ['4.4.*', '5.4.*', '6.0.*'] + php: ['7.4', '8.0', '8.1', '8.2'] + symfony: ['4.4.*', '5.4.*', '6.0.*', '6.1.*', '6.2.*', '6.3.*'] composer-flags: ['--prefer-stable'] can-fail: [false] extensions: ['curl, iconv, mbstring, mongodb, pdo, pdo_sqlite, sqlite, zip'] @@ -23,15 +23,27 @@ jobs: exclude: - php: '7.4' symfony: '6.0.*' + - php: '7.4' + symfony: '6.1.*' + - php: '7.4' + symfony: '6.2.*' + - php: '7.4' + symfony: '6.3.*' + - php: '8.0' + symfony: '6.1.*' + - php: '8.0' + symfony: '6.2.*' + - php: '8.0' + symfony: '6.3.*' name: "PHP ${{ matrix.php }} - Symfony ${{ matrix.symfony }}${{ matrix.composer-flags != '' && format(' - Composer {0}', matrix.composer-flags) || '' }}" steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Cache dependencies - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/.composer/cache/files key: dependencies-symfony-${{ matrix.symfony }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}-flags-${{ matrix.composer-flags }} @@ -52,7 +64,7 @@ jobs: topology: server - name: Remove Guard - if: matrix.symfony == '6.0.*' + if: contains(fromJSON('["6.0.*", "6.1.*", "6.2.*", "6.3.*"]'), matrix.symfony) run: composer remove --dev --no-update symfony/security-guard - name: Install dependencies diff --git a/Model/AbstractRefreshToken.php b/Model/AbstractRefreshToken.php index ee3d5a8f..5cfa3d4d 100644 --- a/Model/AbstractRefreshToken.php +++ b/Model/AbstractRefreshToken.php @@ -41,7 +41,13 @@ abstract class AbstractRefreshToken implements RefreshTokenInterface public static function createForUserWithTtl(string $refreshToken, UserInterface $user, int $ttl): RefreshTokenInterface { $valid = new \DateTime(); - $valid->modify('+'.$ttl.' seconds'); + + // Explicitly check for a negative number based on a behavior change in PHP 8.2, see https://github.com/php/php-src/issues/9950 + if ($ttl > 0) { + $valid->modify('+'.$ttl.' seconds'); + } elseif ($ttl < 0) { + $valid->modify($ttl.' seconds'); + } $model = new static(); $model->setRefreshToken($refreshToken); diff --git a/Security/Http/Authenticator/RefreshTokenAuthenticator.php b/Security/Http/Authenticator/RefreshTokenAuthenticator.php index bf6e0a0b..babd06b5 100644 --- a/Security/Http/Authenticator/RefreshTokenAuthenticator.php +++ b/Security/Http/Authenticator/RefreshTokenAuthenticator.php @@ -116,7 +116,14 @@ public function authenticate(Request $request): Passport if ($this->options['ttl_update']) { $expirationDate = new \DateTime(); - $expirationDate->modify(sprintf('+%d seconds', $this->options['ttl'])); + + // Explicitly check for a negative number based on a behavior change in PHP 8.2, see https://github.com/php/php-src/issues/9950 + if ($this->options['ttl'] > 0) { + $expirationDate->modify(sprintf('+%d seconds', $this->options['ttl'])); + } elseif ($this->options['ttl'] < 0) { + $expirationDate->modify(sprintf('%d seconds', $this->options['ttl'])); + } + $refreshToken->setValid($expirationDate); $this->refreshTokenManager->save($refreshToken); diff --git a/Tests/Unit/Request/Extractor/RequestBodyExtractorTest.php b/Tests/Unit/Request/Extractor/RequestBodyExtractorTest.php index 74e419eb..e2d2e3f1 100644 --- a/Tests/Unit/Request/Extractor/RequestBodyExtractorTest.php +++ b/Tests/Unit/Request/Extractor/RequestBodyExtractorTest.php @@ -59,7 +59,7 @@ private function createMockRequest(?string $contentType, ?array $jsonBodyData = $request ->expects($this->atLeastOnce()) - ->method('getContentType') + ->method(method_exists(Request::class, 'getContentTypeFormat') ? 'getContentTypeFormat' : 'getContentType') ->willReturn($contentType); if (is_array($jsonBodyData)) { diff --git a/Tests/bootstrap.php b/Tests/bootstrap.php deleted file mode 100644 index abd86179..00000000 --- a/Tests/bootstrap.php +++ /dev/null @@ -1,5 +0,0 @@ - @@ -18,7 +18,6 @@ ./Resources ./Tests - ./spec ./vendor