Skip to content

Commit b786213

Browse files
phpstan-botclaude
authored andcommitted
Add rule test for bug 8056 to verify no false positive "Empty array passed to foreach"
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 61c54ae commit b786213

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

tests/PHPStan/Rules/Arrays/DeadForeachRuleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,9 @@ public function testBug2457(): void
5555
$this->analyse([__DIR__ . '/data/bug-2457.php'], []);
5656
}
5757

58+
public function testBug8056(): void
59+
{
60+
$this->analyse([__DIR__ . '/data/bug-8056.php'], []);
61+
}
62+
5863
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug8056Rule;
4+
5+
$array = [];
6+
$tmp = &$array;
7+
$tmp[] = 'foo';
8+
9+
foreach ($array as $i) {
10+
11+
}

0 commit comments

Comments
 (0)