Skip to content

Commit 992768b

Browse files
committed
merge loops
1 parent 6a1c710 commit 992768b

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

src/Analyser/MutatingScope.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4098,32 +4098,24 @@ private function generalizeType(Type $a, Type $b, int $depth): Type
40984098
$max = $int->getValue();
40994099
}
41004100

4101+
$newMin = $min;
4102+
$newMax = $max;
41014103
$gotGreater = false;
41024104
$gotSmaller = false;
41034105
foreach ($constantIntegers['b'] as $int) {
41044106
if ($int->getValue() > $max) {
4107+
$newMax = $int->getValue();
41054108
$gotGreater = true;
41064109
}
41074110
if ($int->getValue() >= $min) {
41084111
continue;
41094112
}
41104113

4114+
$newMin = $int->getValue();
41114115
$gotSmaller = true;
41124116
}
41134117

41144118
if ($gotGreater && $gotSmaller) {
4115-
$newMin = $min;
4116-
$newMax = $max;
4117-
foreach ($constantIntegers['b'] as $int) {
4118-
if ($int->getValue() < $newMin) {
4119-
$newMin = $int->getValue();
4120-
}
4121-
if ($int->getValue() <= $newMax) {
4122-
continue;
4123-
}
4124-
4125-
$newMax = $int->getValue();
4126-
}
41274119
$resultTypes[] = IntegerRangeType::fromInterval($newMin, $newMax);
41284120
} elseif ($gotGreater) {
41294121
$resultTypes[] = IntegerRangeType::fromInterval($min, null);

0 commit comments

Comments
 (0)