Skip to content

[6.x] Fix durationForHumans deprecation warning and rounding#14541

Merged
jasonvarga merged 3 commits into6.xfrom
implicit-conversion-warning
Apr 23, 2026
Merged

[6.x] Fix durationForHumans deprecation warning and rounding#14541
jasonvarga merged 3 commits into6.xfrom
implicit-conversion-warning

Conversation

@duncanmcclean
Copy link
Copy Markdown
Member

This pull request fixes an issue where Str::durationForHumans() emits "Implicit conversion from float to int loses precision" warnings on PHP 8.4 when called with a non-integer duration (e.g. 36.92 seconds from video/audio asset metadata).

This was happening because the % modulo operator was being used directly on the float input, which PHP 8.4 flags as a deprecation warning.

This PR fixes it by casting the input to an integer at the top of the method.

Fixes #14538

@jasonvarga jasonvarga changed the title [6.x] Fix PHP 8.4 implicit float-to-int conversion warning in Str::durationForHumans() [6.x] Fix durationForHumans deprecation warning and rounding Apr 23, 2026
@jasonvarga
Copy link
Copy Markdown
Member

The deprecation warning was pointing out a bug that the precision was being lost. A time of 36.92 seconds should be rendered as 0:37. We may as well fix the rounding issue at the same time.

@jasonvarga jasonvarga merged commit 5864697 into 6.x Apr 23, 2026
18 checks passed
@jasonvarga jasonvarga deleted the implicit-conversion-warning branch April 23, 2026 15:29
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.

PHP 8.4: implicit float-to-int conversion warnings in Str::durationForHumans()

2 participants