Skip to content

Commit 0ca1890

Browse files
phpstan-botclaude
andcommitted
Add regression test for #6991
Closes phpstan/phpstan#6991 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3836343 commit 0ca1890

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php declare(strict_types = 1); // lint >= 8.0
2+
3+
namespace Bug6991;
4+
5+
use function PHPStan\Testing\assertType;
6+
7+
class HelloWorld
8+
{
9+
public int $more = 1;
10+
11+
public ?string $key = null;
12+
}
13+
14+
class Other {
15+
public ?HelloWorld $optional = null;
16+
}
17+
18+
function test(Other $object): int
19+
{
20+
$key = $object->optional?->key;
21+
22+
if (!$key) {
23+
return 0;
24+
}
25+
26+
assertType('Bug6991\HelloWorld', $object->optional);
27+
28+
return $object->optional->more * 100;
29+
}

0 commit comments

Comments
 (0)