Skip to content

Commit ca0e92c

Browse files
committed
Regression tests
Closes phpstan/phpstan#10771
1 parent 617a3a8 commit ca0e92c

2 files changed

Lines changed: 63 additions & 0 deletions

File tree

tests/PHPStan/Rules/Methods/ReturnTypeRuleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,4 +1286,9 @@ public function testBug8438(): void
12861286
$this->analyse([__DIR__ . '/data/bug-8438.php'], []);
12871287
}
12881288

1289+
public function testBug10771(): void
1290+
{
1291+
$this->analyse([__DIR__ . '/data/bug-10771.php'], []);
1292+
}
1293+
12891294
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
namespace Bug10771;
4+
5+
/**
6+
* @template T of Template
7+
*
8+
* @extends B<T>
9+
*/
10+
class A extends B
11+
{
12+
/**
13+
* @return class-string<T>
14+
*/
15+
public function getClassString(): string
16+
{
17+
return static::ENTITY;
18+
}
19+
}
20+
21+
/**
22+
* @template T of Template
23+
*/
24+
class B
25+
{
26+
/** @var class-string<T> */
27+
public const ENTITY = Template::class;
28+
}
29+
30+
class Template
31+
{
32+
33+
}
34+
35+
/**
36+
* @template TA of Template
37+
*
38+
* @extends Bb<TA>
39+
*/
40+
class Aa extends Bb
41+
{
42+
/**
43+
* @return class-string<TA>
44+
*/
45+
public function getClassString(): string
46+
{
47+
return static::ENTITY;
48+
}
49+
}
50+
51+
/**
52+
* @template TB of Template
53+
*/
54+
class Bb
55+
{
56+
/** @var class-string<TB> */
57+
public const ENTITY = Template::class;
58+
}

0 commit comments

Comments
 (0)