Skip to content

Commit adeee63

Browse files
Add non regression test (#5109)
1 parent db44384 commit adeee63

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)