File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
tests/PHPStan/Rules/Variables Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -1517,4 +1517,18 @@ public function testBug11218(): void
15171517 $ this ->analyse ([__DIR__ . '/data/bug-11218.php ' ], []);
15181518 }
15191519
1520+ public function testBug6688 (): void
1521+ {
1522+ $ this ->cliArgumentsVariablesRegistered = true ;
1523+ $ this ->polluteScopeWithLoopInitialAssignments = false ;
1524+ $ this ->checkMaybeUndefinedVariables = true ;
1525+ $ this ->polluteScopeWithAlwaysIterableForeach = true ;
1526+ $ this ->analyse ([__DIR__ . '/data/bug-6688.php ' ], [
1527+ [
1528+ 'Variable $a might not be defined. ' ,
1529+ 5 ,
1530+ ],
1531+ ]);
1532+ }
1533+
15201534}
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types = 1 );
2+
3+ namespace Bug6688 ;
4+
5+ echo $ a ; // possibly undefined
6+
7+ /** @var string $b */
8+ echo $ b ; // willed into existence
9+
10+ /** @var string[] $c */
11+ foreach ($ c as $ v ) { // willed into existence
12+ }
13+
14+ /** @var string[][] $result */
15+ foreach ($ result as $ data ) {
16+ echo '" ' . implode ('", " ' , $ data ) . '" ' . "\n" ;
17+ }
You can’t perform that action at this time.
0 commit comments