Skip to content

Commit d73fc15

Browse files
committed
added regression test
1 parent ec33a67 commit d73fc15

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace Bug13214;
4+
5+
use function PHPStan\Testing\assertType;
6+
use stdClass;
7+
8+
class HelloWorld
9+
{
10+
/**
11+
* @param ArrayAccess<int, ?object> $array
12+
*/
13+
public function sayHello(ArrayAccess $array): void
14+
{
15+
$child = new stdClass();
16+
17+
assert($array[1] === null);
18+
19+
assertType('null', $array[1]);
20+
21+
$array[1] = $child;
22+
23+
assertType(stdClass::class, $array[1]);
24+
}
25+
26+
/**
27+
* @param array<int, ?object> $array
28+
*/
29+
public function sayHelloArray(array $array): void
30+
{
31+
$child = new stdClass();
32+
33+
assert(($array[1] ?? null) === null);
34+
35+
assertType('object|null', $array[1]);
36+
37+
$array[1] = $child;
38+
39+
assertType(stdClass::class, $array[1]);
40+
}
41+
}

0 commit comments

Comments
 (0)