forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbug-13453.php
More file actions
40 lines (32 loc) · 729 Bytes
/
bug-13453.php
File metadata and controls
40 lines (32 loc) · 729 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php // lint >= 8.3
declare(strict_types = 1);
namespace Bug13453;
/** @template T of ResultA */
interface I {
/** @var class-string<T> */
public const string ResultType = ResultA::class;
}
class ResultA {
public function __construct(public string $value) {}
}
class ResultB extends ResultA {
public function rot13(): string { return str_rot13($this->value); }
}
/** @template-implements I<ResultB> */
class In implements I {
public const string ResultType = ResultB::class;
}
/**
* @template T of ResultA
* @param I<T> $in
* @return T
*/
function run(I $in): ResultA {
$value = 'abc';
return new ($in::ResultType)($value);
}
function main(): void {
$in = new In();
$ret = run($in);
print $ret->rot13();
}