Skip to content

Commit 3530dd2

Browse files
committed
add regression test
1 parent 5f3237a commit 3530dd2

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

tests/PHPStan/Rules/Comparison/IfConstantConditionRuleTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,11 @@ public function testBug13384b(): void
194194
]);
195195
}
196196

197+
#[RequiresPhp('>= 7.3')]
198+
public function testBug8270(): void
199+
{
200+
$this->treatPhpDocTypesAsCertain = true;
201+
$this->analyse([__DIR__ . '/data/bug-8270.php'], []);
202+
}
203+
197204
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace Bug8270;
4+
5+
$list = [];
6+
7+
for ($i = 0; $i < 10; $i++) {
8+
$list[] = [
9+
'test' => false,
10+
'value' => rand(),
11+
];
12+
}
13+
14+
// TODO: sort list by value asc...
15+
$k = array_key_first($list);
16+
$list[$k]['test'] = true; // <--- assign only first item!
17+
18+
foreach ($list as $item) {
19+
if ($item['test']) {
20+
echo $item['value'];
21+
}
22+
}
23+

0 commit comments

Comments
 (0)