Skip to content

Commit 4f5f8f5

Browse files
committed
Added regression test
1 parent c6f8126 commit 4f5f8f5

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

tests/PHPStan/Rules/Arrays/DeadForeachRuleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,9 @@ public function testBug13248(): void
4545
$this->analyse([__DIR__ . '/data/bug-13248.php'], []);
4646
}
4747

48+
public function testBug2560(): void
49+
{
50+
$this->analyse([__DIR__ . '/data/bug-2560.php'], []);
51+
}
52+
4853
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace Bug2560;
4+
5+
class HelloWorld
6+
{
7+
public function test(): void
8+
{
9+
$arr = [];
10+
foreach ([0,1] as $i) {
11+
$arr[$i] = [];
12+
array_push($arr[$i], "foo");
13+
}
14+
foreach (array_values($arr) as $vec) {
15+
foreach ($vec as $value) {
16+
print_r("$value");
17+
}
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)