Skip to content

Commit fe92101

Browse files
committed
Create bug-10025.php
1 parent 23295ee commit fe92101

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Bug10025;
4+
5+
use function PHPStan\Testing\assertType;
6+
7+
class MyClass
8+
{
9+
public int $groupId;
10+
}
11+
12+
/**
13+
* @param list<MyClass> $foos
14+
* @param list<MyClass> $bars
15+
*/
16+
function x(array $foos, array $bars): void
17+
{
18+
$arr = [];
19+
foreach ($foos as $foo) {
20+
$arr[$foo->groupId]['foo'][] = $foo;
21+
}
22+
foreach ($bars as $bar) {
23+
$arr[$bar->groupId]['bar'][] = $bar;
24+
}
25+
26+
assertType('array<int, non-empty-array{foo?: non-empty-list<Bug10025\MyClass>, bar?: non-empty-list<Bug10025\MyClass>}>', $arr);
27+
foreach ($arr as $groupId => $group) {
28+
if (isset($group['foo'])) {
29+
}
30+
if (isset($group['bar'])) {
31+
}
32+
}
33+
34+
assertType('array<int, non-empty-array{foo?: non-empty-list<Bug10025\MyClass>, bar?: non-empty-list<Bug10025\MyClass>}>', $arr);
35+
}
36+

0 commit comments

Comments
 (0)