From 83653d57cba8cbd428c298516960c2703e6992f1 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 24 Jul 2024 02:32:05 +1000 Subject: [PATCH 1/3] Cater for both Carbon v2 and v3 - issue #260 --- src/Blacklist.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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)); + } } /** From 4d84dc99f3ebd609f2c56917b9840740e96e87d9 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 24 Jul 2024 22:16:07 +1000 Subject: [PATCH 2/3] Adds a test runner for carbon 3 --- .github/workflows/phpunit.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 23013c32..4c8816b6 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.* + nesbot/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: From e6aab3273651dcc2ec488e7331351d72d0cb1a90 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 24 Jul 2024 22:17:54 +1000 Subject: [PATCH 3/3] Typo --- .github/workflows/phpunit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 4c8816b6..9965043f 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -29,7 +29,7 @@ jobs: coverage: xdebug - php: 8.3 laravel: 11.* - nesbot/carbon: 3.* + carbon: 3.* name: 'P${{ matrix.php }} L${{ matrix.laravel }} ${{ matrix.stability }} c:${{ matrix.coverage }}'