Skip to content

Commit 5d698a2

Browse files
committed
[3.x] Fix ext-uv int into float overflow logic for PHP8.5
This code introduced in #196 relied on behavior that has been changed in PHP8.5 by: https://wiki.php.net/rfc/warnings-php-8-5#casting_out_of_range_floats_to_int
1 parent 941af79 commit 5d698a2

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/ExtUvLoop.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,17 @@ private function convertFloatSecondsToMilliseconds($interval)
326326
}
327327

328328
$maxValue = (int) (\PHP_INT_MAX / 1000);
329-
$intInterval = (int) $interval;
329+
$intervalOverflow = false;
330+
if (PHP_VERSION_ID > 80499 && $interval >= \PHP_INT_MAX + 1) {
331+
$intervalOverflow = true;
332+
} else {
333+
$intInterval = (int) $interval;
334+
if (($intInterval <= 0 && $interval > 1) || $intInterval >= $maxValue) {
335+
$intervalOverflow = true;
336+
}
337+
}
330338

331-
if (($intInterval <= 0 && $interval > 1) || $intInterval >= $maxValue) {
339+
if ($intervalOverflow) {
332340
throw new \InvalidArgumentException(
333341
"Interval overflow, value must be lower than '{$maxValue}', but '{$interval}' passed."
334342
);

0 commit comments

Comments
 (0)