File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed
tests/PHPStan/Rules/Variables Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -1277,14 +1277,30 @@ public function testBug11984(): void
12771277 $ this ->analyse ([__DIR__ . '/data/bug-11984.php ' ], []);
12781278 }
12791279
1280- public function testBug11545 (): void
1280+ #[DataProvider('dataBug11545 ' )]
1281+ public function testBug11545 (bool $ polluteScopeWithLoopInitialAssignments ): void
12811282 {
12821283 $ this ->cliArgumentsVariablesRegistered = true ;
1283- $ this ->polluteScopeWithLoopInitialAssignments = false ;
1284+ $ this ->polluteScopeWithLoopInitialAssignments = $ polluteScopeWithLoopInitialAssignments ;
12841285 $ this ->checkMaybeUndefinedVariables = true ;
12851286 $ this ->polluteScopeWithAlwaysIterableForeach = true ;
12861287
1287- $ this ->analyse ([__DIR__ . '/data/bug-11545.php ' ], []);
1288+ $ errors = [];
1289+ if (!$ polluteScopeWithLoopInitialAssignments ) {
1290+ $ errors [] = [
1291+ 'Variable $result might not be defined. ' ,
1292+ 24 ,
1293+ ];
1294+ }
1295+
1296+ $ this ->analyse ([__DIR__ . '/data/bug-11545.php ' ], $ errors );
1297+ }
1298+
1299+ /** @return iterable<array{bool}> */
1300+ public static function dataBug11545 (): iterable
1301+ {
1302+ yield [false ];
1303+ yield [true ];
12881304 }
12891305
12901306 public function testBug10245 (): void
You can’t perform that action at this time.
0 commit comments