Skip to content

Commit beb28b4

Browse files
phpstan-botclaude
authored andcommitted
Add regression test for #12562
Closes phpstan/phpstan#12562 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7f8a6f1 commit beb28b4

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php declare(strict_types = 1); // lint >= 8.0
2+
3+
namespace Bug12562;
4+
5+
use function PHPStan\Testing\assertType;
6+
7+
class UserV1
8+
{
9+
public function toV2(): UserV2
10+
{
11+
return new UserV2();
12+
}
13+
}
14+
15+
class UserV2
16+
{
17+
public function toV2(): self
18+
{
19+
return $this;
20+
}
21+
}
22+
23+
class UserV2a extends UserV2
24+
{
25+
/**
26+
* @return $this
27+
*/
28+
public function toV2(): self
29+
{
30+
return $this;
31+
}
32+
}
33+
34+
function doSomething(UserV1|UserV2 $user, UserV1|UserV2a $user2): void
35+
{
36+
assertType('Bug12562\UserV2', $user->toV2());
37+
assertType('Bug12562\UserV2', $user2->toV2());
38+
}

0 commit comments

Comments
 (0)