Skip to content

Commit

Permalink
fix for big int-ranges
Browse files Browse the repository at this point in the history
fix issue #6375
  • Loading branch information
voku committed Jan 21, 2022
1 parent 1aef99d commit e283c94
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Type/Constant/ConstantArrayTypeBuilder.php
Expand Up @@ -104,14 +104,17 @@ public function setOffsetValueType(?Type $offsetType, Type $valueType, bool $opt
$integerRanges = TypeUtils::getIntegerRanges($offsetType);
if (count($integerRanges) > 0) {
foreach ($integerRanges as $integerRange) {
if ($integerRange->getMin() === null) {
$minRange = $integerRange->getMin();
if ($minRange === null || $minRange <= self::ARRAY_COUNT_LIMIT) {
break;
}
if ($integerRange->getMax() === null) {

$maxRange = $integerRange->getMax();
if ($maxRange === null || $maxRange >= self::ARRAY_COUNT_LIMIT) {
break;
}

foreach (range($integerRange->getMin(), $integerRange->getMax()) as $rangeValue) {
foreach (range($minRange, $maxRange) as $rangeValue) {
$scalarTypes[] = new ConstantIntegerType($rangeValue);
}
}
Expand Down

0 comments on commit e283c94

Please sign in to comment.