Skip to content

Commit aa908f9

Browse files
committed
[1.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 cbc17ca commit aa908f9

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
@@ -329,9 +329,17 @@ private function convertFloatSecondsToMilliseconds($interval)
329329
}
330330

331331
$maxValue = (int) (\PHP_INT_MAX / 1000);
332-
$intInterval = (int) $interval;
332+
$intervalOverflow = false;
333+
if (PHP_VERSION_ID > 80499 && $interval >= \PHP_INT_MAX + 1) {
334+
$intervalOverflow = true;
335+
} else {
336+
$intInterval = (int) $interval;
337+
if (($intInterval <= 0 && $interval > 1) || $intInterval >= $maxValue) {
338+
$intervalOverflow = true;
339+
}
340+
}
333341

334-
if (($intInterval <= 0 && $interval > 1) || $intInterval >= $maxValue) {
342+
if ($intervalOverflow) {
335343
throw new \InvalidArgumentException(
336344
"Interval overflow, value must be lower than '{$maxValue}', but '{$interval}' passed."
337345
);

0 commit comments

Comments
 (0)