[8.x] Ensure int type of getSeconds() output #41623
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 saysint
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 🙏