diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 23013c32..9965043f 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -27,6 +27,9 @@ jobs: laravel: 11.* stability: prefer-stable coverage: xdebug + - php: 8.3 + laravel: 11.* + carbon: 3.* name: 'P${{ matrix.php }} L${{ matrix.laravel }} ${{ matrix.stability }} c:${{ matrix.coverage }}' @@ -55,6 +58,11 @@ jobs: run: | composer require "illuminate/contracts:${{ matrix.laravel }}" --no-interaction --no-progress --no-update + - name: Set carbon version + if: ${{ matrix.carbon }} + run: | + composer require "nesbot/carbon:${{ matrix.carbon }}" --no-interaction --no-progress --no-update + - name: Cache dependencies uses: actions/cache@v4 with: diff --git a/src/Blacklist.php b/src/Blacklist.php index 746c96d8..d0107626 100644 --- a/src/Blacklist.php +++ b/src/Blacklist.php @@ -95,7 +95,14 @@ protected function getMinutesUntilExpired(Payload $payload) // get the latter of the two expiration dates and find // the number of minutes until the expiration date, // plus 1 minute to avoid overlap - return round($exp->max($iat->addMinutes($this->refreshTTL))->addMinute()->diffInRealMinutes(null, true)); + $intermediateResult = $exp->max($iat->addMinutes($this->refreshTTL))->addMinute(); + + // Handle Carbon 2 vs 3 deprecation of "Real" diff functions, see https://github.com/PHP-Open-Source-Saver/jwt-auth/issues/260 + if (method_exists($intermediateResult, 'diffInRealMinutes')) { + return round($intermediateResult->diffInRealMinutes(null, true)); + } else { + return (int) round($intermediateResult->diffInMinutes(null, true)); + } } /**