Skip to content

Commit 981c7ba

Browse files
committed
Regression test
Closes phpstan/phpstan#5086
1 parent 7eb66f6 commit 981c7ba

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

tests/PHPStan/Analyser/NodeScopeResolverTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ public function dataFileAsserts(): iterable
121121
yield from $this->gatherAssertTypes(__DIR__ . '/data/inherit-phpdoc-merging-template.php');
122122
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-3266.php');
123123
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-3269.php');
124+
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-5086.php');
124125
yield from $this->gatherAssertTypes(__DIR__ . '/data/assign-nested-arrays.php');
125126
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-3276.php');
126127
yield from $this->gatherAssertTypes(__DIR__ . '/../Rules/Methods/data/bug-6856.php');
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace Bug5086;
4+
5+
use stdClass;
6+
use function PHPStan\Testing\assertType;
7+
8+
class Foo
9+
{
10+
11+
public function doFoo(): ?object
12+
{
13+
14+
}
15+
16+
public function doBar(): void
17+
{
18+
/** @var stdClass $obj */
19+
if (!($obj = $this->doFoo())) {
20+
return;
21+
}
22+
23+
assertType(stdClass::class, $obj);
24+
}
25+
26+
}

0 commit comments

Comments
 (0)