Skip to content

Commit 874e5a4

Browse files
committed
Regression test
Closes phpstan/phpstan#4612
1 parent cdd0806 commit 874e5a4

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,4 +1406,9 @@ public function testJsonValidate(): void
14061406
]);
14071407
}
14081408

1409+
public function testBug4612(): void
1410+
{
1411+
$this->analyse([__DIR__ . '/data/bug-4612.php'], []);
1412+
}
1413+
14091414
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace Bug4612;
4+
5+
function check(int $param): bool { return true; }
6+
7+
/** @var array<int, int> $array */
8+
$array = [];
9+
10+
foreach ($array as $k => $v) {
11+
if (check($k) && isset($prev)) {
12+
$array[$prev] = $v;
13+
}
14+
15+
$prev = $k;
16+
}

0 commit comments

Comments
 (0)