We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1bbe9dc commit bdf447eCopy full SHA for bdf447e
1 file changed
tests/PHPStan/Analyser/nsrt/pr-5108.php
@@ -0,0 +1,43 @@
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
0 commit comments