Skip to content

Commit

Permalink
fix: Implicit conversion from float to int loses precision
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanzhihai committed Sep 13, 2023
1 parent 66c6908 commit 9493048
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/throttle/TokenBucket.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function allowRequest(string $key, float $micronow, int $max_requests, in

if ($token_left < 1) {
$tmp = (int)ceil($duration / $max_requests);
$this->wait_seconds = $tmp - ($micronow - $last_time) % $tmp;
$this->wait_seconds = $tmp - intval(($micronow - $last_time)) % $tmp;
return false;
}
$this->cur_requests = $max_requests - $token_left;
Expand Down

0 comments on commit 9493048

Please sign in to comment.