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

[8.x] Ensure int type of getSeconds() output #41623

Merged
merged 1 commit into from
Mar 23, 2022

Conversation

kylekatarnls
Copy link
Contributor

Hello 👋 In Carbon 3, diff* will return a float (current behavior of floatDiff*) so value is never truncated and result will be less surprising when having 0.999 day or the like.

getSeconds() PHPDoc says int and it sounds like the intent behind the (int) cast was to ensure it, but due to operator precedence, it's actually doing ((int) $duration) > 0 ? $duration : 0 so the type of the return is actually not in control of the method. Make the cast as the last step ensure it.

Side note: it's present from 6.x to master, I can change the branch if 6.x/7.x should still be supported.

Thanks 🙏

@GrahamCampbell
Copy link
Member

6.x is just security fixes now, and 7.x it completely EOL. 8.x is the right place for this.

@GrahamCampbell GrahamCampbell changed the title Ensure int type of getSeconds() output [8.x] Ensure int type of getSeconds() output Mar 22, 2022
@taylorotwell taylorotwell merged commit 447f620 into laravel:8.x Mar 23, 2022
@kylekatarnls kylekatarnls deleted the patch-11 branch March 23, 2022 15:41
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.

3 participants