Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions tests/PHPStan/Rules/Variables/DefinedVariableRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
]);
}

}
17 changes: 17 additions & 0 deletions tests/PHPStan/Rules/Variables/data/bug-6688.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php declare(strict_types = 1);

namespace Bug6688;

echo $a; // possibly undefined

/** @var string $b */
echo $b; // willed into existence

/** @var string[] $c */
foreach ($c as $v) { // willed into existence
}

/** @var string[][] $result */
foreach ($result as $data) {
echo '"' . implode('", "', $data) . '"' . "\n";
}
Loading