Skip to content

Commit c9c74c5

Browse files
committed
Regression test
Closes phpstan/phpstan#10650
1 parent fac96bf commit c9c74c5

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Bug10650;
4+
5+
use function PHPStan\Testing\assertType;
6+
7+
class DistFoo
8+
{
9+
/**
10+
* @param list<'y'> $distPoints
11+
*/
12+
public function repro(array $distPoints): void
13+
{
14+
$ranges = [];
15+
$pointPrev = null;
16+
foreach ($distPoints as $distPoint) {
17+
if ($pointPrev !== null) {
18+
$ranges[] = 'x';
19+
}
20+
$pointPrev = $distPoint;
21+
}
22+
23+
assertType('list<\'x\'>', $ranges);
24+
25+
foreach (array_keys($ranges) as $key) {
26+
if (mt_rand() === 0) {
27+
unset($ranges[$key]);
28+
}
29+
}
30+
31+
assertType('array<int<0, max>, \'x\'>', $ranges);
32+
}
33+
}

0 commit comments

Comments
 (0)