-
Notifications
You must be signed in to change notification settings - Fork 574
Expand file tree
/
Copy pathbug-10025.php
More file actions
36 lines (29 loc) · 831 Bytes
/
bug-10025.php
File metadata and controls
36 lines (29 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php declare(strict_types=1);
namespace Bug10025;
use function PHPStan\Testing\assertType;
class MyClass
{
public int $groupId;
}
/**
* @param list<MyClass> $foos
* @param list<MyClass> $bars
*/
function x(array $foos, array $bars): void
{
$arr = [];
foreach ($foos as $foo) {
$arr[$foo->groupId]['foo'][] = $foo;
}
foreach ($bars as $bar) {
$arr[$bar->groupId]['bar'][] = $bar;
}
assertType('non-empty-array<int, array{foo?: non-empty-list<Bug10025\MyClass>, bar: non-empty-list<Bug10025\MyClass>}>|array<int, array{foo: non-empty-list<Bug10025\MyClass>}>', $arr);
foreach ($arr as $groupId => $group) {
if (isset($group['foo'])) {
}
if (isset($group['bar'])) {
}
}
assertType('array<int, non-empty-array{foo?: non-empty-list<Bug10025\MyClass>, bar?: non-empty-list<Bug10025\MyClass>}>', $arr);
}