Skip to content

Commit 2b68f49

Browse files
committed
regression test
1 parent 9f0b378 commit 2b68f49

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

tests/PHPStan/Rules/Variables/DefinedVariableRuleTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,6 +1353,16 @@ public function testBug5477(): void
13531353
$this->analyse([__DIR__ . '/data/bug-5477.php'], []);
13541354
}
13551355

1356+
public function testBug10657(): void
1357+
{
1358+
$this->cliArgumentsVariablesRegistered = true;
1359+
$this->polluteScopeWithLoopInitialAssignments = false;
1360+
$this->checkMaybeUndefinedVariables = true;
1361+
$this->polluteScopeWithAlwaysIterableForeach = true;
1362+
1363+
$this->analyse([__DIR__ . '/data/bug-10657.php'], []);
1364+
}
1365+
13561366
public function testBug14117(): void
13571367
{
13581368
$this->cliArgumentsVariablesRegistered = true;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace Bug10657;
4+
5+
class HelloWorld
6+
{
7+
public function sayHello(bool $flag): void
8+
{
9+
for ($i = 0; $i < 10; $i++) {
10+
if ($flag) {
11+
$foo = 'bar';
12+
}
13+
if ($flag) {
14+
echo $foo;
15+
}
16+
}
17+
}
18+
}

0 commit comments

Comments
 (0)