File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
tests/PHPStan/Analyser/nsrt Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments