You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm receiving following errors in my application PHP Deprecation Notice: Implicit conversion from float 59999985.93330383 to int loses precision in /var/www/html/vendor/symfony/rate-limiter/Reservation.php line 48
The usleep function accepts int as parameter type (https://www.php.net/manual/en/function.usleep.php), while the passed type is float in Reservation::wait (due to Reservation::getWaitDuration returning a float value for the 1e6 multiplication)
…eak)
This PR was submitted for the 6.3 branch but it was merged into the 5.4 branch instead.
Discussion
----------
[RateLimiter] Add `int` to `Reservation::wait()`
| Q | A
| ------------- | ---
| Branch? | 5.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix#48500
| License | MIT
The `usleep` function accepts int as parameter type (https://www.php.net/manual/en/function.usleep.php), while the passed type is float in `Reservation::wait` (due to `Reservation::getWaitDuration` returning a float value for the 1e6 multiplication)
To prevent deprecation notices we can typecast the float value to int before passing it to `usleep`
Commits
-------
6ad3279 [RateLimiter] Add typecast to Reservation::wait
Symfony version(s) affected
6.2.0
Description
I'm receiving following errors in my application
PHP Deprecation Notice: Implicit conversion from float 59999985.93330383 to int loses precision in /var/www/html/vendor/symfony/rate-limiter/Reservation.php line 48
The usleep function accepts int as parameter type (https://www.php.net/manual/en/function.usleep.php), while the passed type is float in
Reservation::wait
(due toReservation::getWaitDuration
returning a float value for the 1e6 multiplication)How to reproduce
Possible Solution
type casting the resulting wait time from float to int fixes the problem
usleep((int) ($this->getWaitDuration() * 1e6));
Additional Context
No response
The text was updated successfully, but these errors were encountered: