Skip to content

Commit 0da93b4

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

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug13358;
4+
5+
use function PHPStan\Testing\assertType;
6+
7+
/**
8+
* @phpstan-sealed SystemActor|AnonymousVisitorActor
9+
*/
10+
abstract class Actor
11+
{
12+
/**
13+
* @phpstan-assert-if-true SystemActor $this
14+
*/
15+
public function isSystem() : bool
16+
{
17+
return $this instanceof SystemActor;
18+
}
19+
20+
/**
21+
* @phpstan-assert-if-true AnonymousVisitorActor $this
22+
*/
23+
public function isAnonymousVisitor() : bool
24+
{
25+
return $this instanceof AnonymousVisitorActor;
26+
}
27+
}
28+
29+
class SystemActor extends Actor
30+
{
31+
}
32+
33+
class AnonymousVisitorActor extends Actor
34+
{
35+
}
36+
37+
function (AnonymousVisitorActor|SystemActor $actor): void {
38+
assertType('Bug13358\AnonymousVisitorActor|Bug13358\SystemActor', $actor);
39+
40+
if ($actor->isSystem()) {
41+
assertType('Bug13358\SystemActor', $actor);
42+
} else {
43+
assertType('Bug13358\AnonymousVisitorActor', $actor);
44+
}
45+
};

0 commit comments

Comments
 (0)