forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbug-3028.php
More file actions
54 lines (42 loc) · 945 Bytes
/
bug-3028.php
File metadata and controls
54 lines (42 loc) · 945 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php declare(strict_types = 1);
namespace Bug3028;
interface Output { }
final class OutputImpl1 implements Output { }
final class OutputImpl2 implements Output { }
/** @psalm-template O of Output */
interface Format
{
/** @psalm-return O */
public function output() : Output;
/** @psalm-param O $o */
public function replace(Output $o) : void;
}
/** @implements Format<OutputImpl1> */
final class FormatImpl1 implements Format
{
public OutputImpl1 $o;
public function __construct() {
$this->o = new OutputImpl1;
}
public function output() : Output
{
return new OutputImpl1();
}
/**
* @param OutputImpl1 $o
*/
public function replace(Output $o) : void
{
$this->o = $o;
}
}
/**
* @psalm-template O of Output
* @psalm-param Format<O> $outputFormat
* @return Format<Output>
*/
function run(Format $outputFormat) : Format {
return $outputFormat;
}
$a = new FormatImpl1;
run($a)->replace(new OutputImpl2);