File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
tests/PHPStan/Rules/Comparison Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff line change 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+
You can’t perform that action at this time.
0 commit comments