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

return an integer in SleepDeferrer->getCurrentTime #6

Closed
wants to merge 1 commit into from

Conversation

digibart
Copy link

because according to php documentation round() returns a float

on PHP v7.3.2 Windows this throws an exception:

 Symfony\Component\Debug\Exception\FatalThrowableError  : Return value of Spatie\GuzzleRateLimiterMiddleware\SleepDeferrer::getCurrentTime() must be of the type int, float returned

  at C:\xampp\httpdocs\vendor\spatie\guzzle-rate-limiter-middleware\src\SleepDeferrer.php:9
     5| class SleepDeferrer implements Deferrer
     6| {
     7|     public function getCurrentTime(): int
     8|     {
  >  9|         return round(microtime(true) * 1000);
    10|     }
    11|
    12|     public function sleep(int $milliseconds)
    13|     {

@digibart
Copy link
Author

hmzz.. on a 32bit system PHP_INT_MAX is 2147483647, that is less then current microtime 1573737486894.

thus, casting it to integer is wrong on a 32 bit system.

I guess 32bit is obsolete, or at least deprecated

@digibart digibart closed this Nov 14, 2019
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.

None yet

1 participant