-
Notifications
You must be signed in to change notification settings - Fork 555
Expand file tree
/
Copy pathbug-11687.php
More file actions
60 lines (50 loc) · 935 Bytes
/
bug-11687.php
File metadata and controls
60 lines (50 loc) · 935 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
55
56
57
58
59
60
<?php declare(strict_types = 1);
namespace Bug11687;
use function PHPStan\Testing\assertType;
class A
{
public static function retStaticConst(): int
{
return 1;
}
/**
* @return static
*/
public static function retStatic()
{
return new static(); // @phpstan-ignore new.static
}
}
class B extends A
{
/**
* @return 2
*/
public static function retStaticConst(): int
{
return 2;
}
public function foo(): void
{
$clUnioned = mt_rand() === 0
? A::class
: X::class;
assertType('int', A::retStaticConst());
assertType('bool', X::retStaticConst());
assertType('bool|int', $clUnioned::retStaticConst());
assertType('Bug11687\A', A::retStatic());
assertType('bool', X::retStatic());
assertType('bool|Bug11687\A', $clUnioned::retStatic());
}
}
class X
{
public static function retStaticConst(): bool
{
return false;
}
public static function retStatic(): bool
{
return false;
}
}