File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
tests/PHPStan/Analyser/nsrt Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php declare (strict_types = 1 );
2+
3+ namespace Pr5108 ;
4+
5+ use function PHPStan \Testing \assertType ;
6+
7+ class A
8+ {
9+ }
10+
11+ interface I
12+ {
13+ function method (): void ;
14+ }
15+
16+ class Testing
17+ {
18+ /**
19+ * @param A|null $arg
20+ * @param-out ($arg is null ? A&I : A) $arg
21+ */
22+ public static function testMethod (?A &$ arg = null ): void
23+ {
24+ if ($ arg === null ) {
25+ $ arg = new A ();
26+ }
27+ }
28+
29+ public function doTest (A $ a ): void
30+ {
31+ Testing::testMethod ($ a );
32+ assertType ('Pr5108\A ' , $ a );
33+
34+ $ b = null ;
35+ Testing::testMethod ($ b );
36+ assertType ('Pr5108\A&Pr5108\I ' , $ b );
37+
38+ $ d = $ a ->getFoo ();
39+ assertType ('*ERROR* ' , $ d );
40+ Testing::testMethod ($ d );
41+ assertType ('Pr5108\A ' , $ d );
42+ }
43+ }
You can’t perform that action at this time.
0 commit comments