Skip to content

Commit 14a2154

Browse files
committed
Revert "Apply symmetric fix for integer range generalization in gotGreater && gotSmaller case"
This reverts commit 92fe388.
1 parent 92fe388 commit 14a2154

2 files changed

Lines changed: 1 addition & 53 deletions

File tree

src/Analyser/MutatingScope.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4204,19 +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-
$rangeMin = $range->getMin();
4211-
$rangeMax = $range->getMax();
4212-
if ($newMin !== null && ($rangeMin === null || $rangeMin < $newMin)) {
4213-
$newMin = $rangeMin;
4214-
}
4215-
if ($newMax !== null && ($rangeMax === null || $rangeMax > $newMax)) {
4216-
$newMax = $rangeMax;
4217-
}
4218-
}
4219-
$resultTypes[] = IntegerRangeType::fromInterval($newMin, $newMax);
4207+
$resultTypes[] = new IntegerType();
42204208
} elseif ($gotGreater) {
42214209
$resultTypes[] = IntegerRangeType::fromInterval($min, null);
42224210
} elseif ($gotSmaller) {

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

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -70,46 +70,6 @@ public function iterateRowColumnIndicesDecrementing(int $rows, int $columns, int
7070
}
7171
}
7272

73-
class Test4
74-
{
75-
/**
76-
* @param int<0, 10> $index
77-
*/
78-
public function integerRangeGeneralization(int $rows, int $index): void
79-
{
80-
if ($rows < 1) return;
81-
82-
for ($i = 0; $i < $rows; $i++) {
83-
assertType('int<-3, 13>', $index);
84-
if ($index > 5) {
85-
$index++;
86-
} else {
87-
$index--;
88-
}
89-
}
90-
}
91-
}
92-
93-
class Test5
94-
{
95-
/**
96-
* @param int<5, 15> $index
97-
*/
98-
public function integerRangeGeneralizationBothDirections(int $rows, int $index): void
99-
{
100-
if ($rows < 1) return;
101-
102-
for ($i = 0; $i < $rows; $i++) {
103-
assertType('int<-10, max>', $index);
104-
if ($index > 10) {
105-
$index++;
106-
} else {
107-
$index = -$index;
108-
}
109-
}
110-
}
111-
}
112-
11373
class Bug12163
11474
{
11575
/**

0 commit comments

Comments
 (0)