Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Carbon^3 #236

Merged
merged 3 commits into from
Mar 17, 2024
Merged

Conversation

mfn
Copy link
Contributor

@mfn mfn commented Mar 17, 2024

Summary

Laravel 11 support was recently added via #233

Laravel 11 supports both carbon 2 & 3, see https://github.com/laravel/framework/blob/ae2f9413b5bd8637c363e6fafffda31c88e56c9e/composer.json#L39

"nesbot/carbon": "^2.72.2|^3.0",

However, projects running Laravel 11 and also requiring carbon:^3 (or have other dependencies requiring it), cannot install jwt-auth because we still only support carbon^2.

This PR fixes that, see also #230 (comment)

Overview of changes

  • Runs tests on 8.3 too

  • Remove carbon^1
    There was no constellation possible which actually used it. Even Laravel 6 with prefer-lowest did install carbon^2, see any random run, e.g. https://github.com/PHP-Open-Source-Saver/jwt-auth/actions/runs/8252381702/job/22571741990#step:11:34

    [PHP 7.4] [Laravel 6.* - prefer-lowest]

    - Locking nesbot/carbon (2.31.0)

  • Add support for carbon^3
    Carbon 3 has some breaking changes and one of them affected the Method diffInRealMinutes we call from \PHPOpenSourceSaver\JWTAuth\Blacklist::getMinutesUntilExpired

    • the result was negative, i.e. -2…
    • the result was a float, i.e. had a decimal point: .9…

    The change using round() and adding a 2nd arg true keeps the code BC.
    Without the fix, tests in \PHPOpenSourceSaver\JWTAuth\Test\BlacklistTest would fail

mfn added 3 commits March 17, 2024 15:19
There is no combination with Laravel which supports Carbon 1 anymore.
Even Laravel 6 requires carbon:^2
Adjust getMinutesUntilExpired() to be compatible with existing behavior.

Before carbon^3, the result was a rounded integer. With carbon^3, the
result was:
- negative (-2....)
- a decimal (.9....)

Rounding and adding the second `true` parameter keeps in BC.
@mfn mfn mentioned this pull request Mar 17, 2024
@Messhias Messhias merged commit 41e6a74 into PHP-Open-Source-Saver:main Mar 17, 2024
33 checks passed
@mfn mfn deleted the mfn-carbon-3 branch March 18, 2024 08:10
@mfn
Copy link
Contributor Author

mfn commented Mar 18, 2024

@Messhias thanks for merging, can you please make a new release too?

@mfn mfn mentioned this pull request Mar 18, 2024
3 tasks
@Messhias
Copy link
Collaborator

@Messhias thanks for merging, can you please make a new release too?

Ok, I'll release it right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants