Skip to content

Commit f083c2e

Browse files
committed
Regression test
Closes phpstan/phpstan#10131
1 parent 5a8168f commit f083c2e

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

tests/PHPStan/Analyser/NodeScopeResolverTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ public function dataFileAsserts(): iterable
173173
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-3875.php');
174174
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-2611.php');
175175
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-3548.php');
176+
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-10131.php');
176177
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-3866.php');
177178
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-1014.php');
178179
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-pr-339.php');
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace Bug10131;
4+
5+
use function PHPStan\Testing\assertType;
6+
7+
class A {
8+
}
9+
10+
class B {
11+
public A|null $a = null;
12+
}
13+
14+
/**
15+
* @phpstan-return array{0:A|null, 1:B|null}
16+
*/
17+
function foo(A|null $a, B|null $b): array
18+
{
19+
$a ??= $b?->a ?? throw new \Exception();
20+
21+
assertType(A::class, $a);
22+
assertType(B::class . '|null', $b);
23+
24+
return [$a, $b];
25+
}

0 commit comments

Comments
 (0)