Skip to content

Commit 01f7ac0

Browse files
Add test
1 parent ba4a7cf commit 01f7ac0

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace Bug13144;
4+
5+
use ArrayObject;
6+
7+
use function PHPStan\Testing\assertType;
8+
9+
$arr = new ArrayObject(['a' => 1, 'b' => 2]);
10+
11+
assertType('ArrayObject<string, int>', $arr); // correctly inferred as `ArrayObject<string, int>`
12+
13+
$a = $arr['a']; // ok
14+
$b = $arr['b']; // ok
15+
16+
assertType('int|null', $a); // correctly inferred as `int|null`
17+
assertType('int|null', $b); // correctly inferred as `int|null`
18+
19+
20+
['a' => $a, 'b' => $b] = $arr; // ok
21+
22+
assertType('int|null', $a); // incorrectly inferred as `mixed`
23+
assertType('int|null', $b); // incorrectly inferred as `mixed`

0 commit comments

Comments
 (0)