Skip to content

Commit 113652b

Browse files
committed
Revert "Apply symmetric fix for integer range generalization in gotGreater && gotSmaller case"
This reverts commit bd09833.
1 parent 2bb5070 commit 113652b

2 files changed

Lines changed: 1 addition & 49 deletions

File tree

src/Analyser/MutatingScope.php

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4204,37 +4204,7 @@ private function generalizeType(Type $a, Type $b, int $depth): Type
42044204
}
42054205

42064206
if ($gotGreater && $gotSmaller) {
4207-
$newMin = $min;
4208-
$newMax = $max;
4209-
foreach ($integerRanges['b'] as $range) {
4210-
if ($range->getMin() === null) {
4211-
$rangeMin = PHP_INT_MIN;
4212-
} else {
4213-
$rangeMin = $range->getMin();
4214-
}
4215-
if ($range->getMax() === null) {
4216-
$rangeMax = PHP_INT_MAX;
4217-
} else {
4218-
$rangeMax = $range->getMax();
4219-
}
4220-
4221-
if ($rangeMin < $newMin) {
4222-
$newMin = $rangeMin;
4223-
}
4224-
if ($rangeMax <= $newMax) {
4225-
continue;
4226-
}
4227-
4228-
$newMax = $rangeMax;
4229-
}
4230-
4231-
if ($newMin === PHP_INT_MIN) {
4232-
$newMin = null;
4233-
}
4234-
if ($newMax === PHP_INT_MAX) {
4235-
$newMax = null;
4236-
}
4237-
$resultTypes[] = IntegerRangeType::fromInterval($newMin, $newMax);
4207+
$resultTypes[] = new IntegerType();
42384208
} elseif ($gotGreater) {
42394209
$resultTypes[] = IntegerRangeType::fromInterval($min, null);
42404210
} elseif ($gotSmaller) {

tests/PHPStan/Analyser/nsrt/bug-12163.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,3 @@ public function iterateRowColumnIndicesDecrementing(int $rows, int $columns, int
6969
}
7070
}
7171
}
72-
73-
class Test4
74-
{
75-
/**
76-
* @param int<5, 10> $index
77-
*/
78-
public function integerRangeGrowsBothDirections(int $size, int $index): void
79-
{
80-
for ($i = 0; $i < $size; $i++) {
81-
assertType('int<3, 12>', $index);
82-
if ($index > 7) {
83-
/** @var int<3, 4> $index */
84-
} else {
85-
$index = $index + 5;
86-
}
87-
}
88-
}
89-
}

0 commit comments

Comments
 (0)