/
bug-8486.php
88 lines (70 loc) · 1.58 KB
/
bug-8486.php
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php // lint >= 8.1
namespace Bug8486;
use function PHPStan\Testing\assertType;
enum Operator: string
{
case Foo = 'foo';
case Bar = 'bar';
case None = '';
public function explode(): void
{
$character = match ($this) {
self::None => 'baz',
default => $this->value,
};
assertType("'bar'|'baz'|'foo'", $character);
}
public function typeInference(): void
{
match ($this) {
self::None => 'baz',
default => assertType('$this(Bug8486\Operator~Bug8486\Operator::None)', $this),
};
}
public function typeInference2(): void
{
if ($this === self::None) {
return;
}
assertType("'Bar'|'Foo'", $this->name);
assertType("'bar'|'foo'", $this->value);
}
}
class Foo
{
public function doFoo(Operator $operator)
{
$character = match ($operator) {
Operator::None => 'baz',
default => $operator->value,
};
assertType("'bar'|'baz'|'foo'", $character);
}
public function typeInference(Operator $operator): void
{
match ($operator) {
Operator::None => 'baz',
default => assertType('Bug8486\Operator~Bug8486\Operator::None', $operator),
};
}
public function typeInference2(Operator $operator): void
{
if ($operator === Operator::None) {
return;
}
assertType("'Bar'|'Foo'", $operator->name);
assertType("'bar'|'foo'", $operator->value);
}
public function typeInference3(Operator $operator): void
{
if ($operator === Operator::None) {
return;
}
if ($operator === Operator::Foo) {
return;
}
assertType("Bug8486\Operator::Bar", $operator);
assertType("'Bar'", $operator->name);
assertType("'bar'", $operator->value);
}
}