Skip to content

Commit 0fc8b96

Browse files
committed
don't cast strings exceeding the min/max int ranges
1 parent e54b060 commit 0fc8b96

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Inline.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,10 @@ private static function evaluateScalar(string $scalar, int $flags, array &$refer
701701
switch (true) {
702702
case ctype_digit($scalar):
703703
case '-' === $scalar[0] && ctype_digit(substr($scalar, 1)):
704+
if ($scalar < \PHP_INT_MIN || \PHP_INT_MAX < $scalar) {
705+
return $scalar;
706+
}
707+
704708
$cast = (int) $scalar;
705709

706710
return ($scalar === (string) $cast) ? $cast : $scalar;

0 commit comments

Comments
 (0)