Skip to content

Commit 0d3dd3a

Browse files
committed
added test
1 parent 2b68f49 commit 0d3dd3a

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
@@ -1363,6 +1363,16 @@ public function testBug10657(): void
13631363
$this->analyse([__DIR__ . '/data/bug-10657.php'], []);
13641364
}
13651365

1366+
public function testBug6830(): void
1367+
{
1368+
$this->cliArgumentsVariablesRegistered = true;
1369+
$this->polluteScopeWithLoopInitialAssignments = false;
1370+
$this->checkMaybeUndefinedVariables = true;
1371+
$this->polluteScopeWithAlwaysIterableForeach = true;
1372+
1373+
$this->analyse([__DIR__ . '/data/bug-6830.php'], []);
1374+
}
1375+
13661376
public function testBug14117(): void
13671377
{
13681378
$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+
declare(strict_types=1);
4+
5+
namespace Bug6830;
6+
7+
/** @param array<bool> $bools */
8+
function test(array $bools): void
9+
{
10+
foreach ($bools as $bool) {
11+
if ($bool) {
12+
$foo = 'foo';
13+
}
14+
if ($bool) {
15+
echo $foo;
16+
}
17+
}
18+
}

0 commit comments

Comments
 (0)