diff --git a/tests/PHPStan/Rules/Variables/DefinedVariableRuleTest.php b/tests/PHPStan/Rules/Variables/DefinedVariableRuleTest.php index 207070c762..6da8dfb7a5 100644 --- a/tests/PHPStan/Rules/Variables/DefinedVariableRuleTest.php +++ b/tests/PHPStan/Rules/Variables/DefinedVariableRuleTest.php @@ -1517,4 +1517,18 @@ public function testBug11218(): void $this->analyse([__DIR__ . '/data/bug-11218.php'], []); } + public function testBug6688(): void + { + $this->cliArgumentsVariablesRegistered = true; + $this->polluteScopeWithLoopInitialAssignments = false; + $this->checkMaybeUndefinedVariables = true; + $this->polluteScopeWithAlwaysIterableForeach = true; + $this->analyse([__DIR__ . '/data/bug-6688.php'], [ + [ + 'Variable $a might not be defined.', + 5, + ], + ]); + } + } diff --git a/tests/PHPStan/Rules/Variables/data/bug-6688.php b/tests/PHPStan/Rules/Variables/data/bug-6688.php new file mode 100644 index 0000000000..c1c98925c2 --- /dev/null +++ b/tests/PHPStan/Rules/Variables/data/bug-6688.php @@ -0,0 +1,17 @@ +