forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbug-5865.php
More file actions
65 lines (53 loc) · 1.08 KB
/
bug-5865.php
File metadata and controls
65 lines (53 loc) · 1.08 KB
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
<?php
namespace Bug5865;
final class HelloWorld
{
public function alwaysThrows(): void
{
throw new \Exception();
}
public function doWhileLiteralTrue(): void
{
do {
$this->alwaysThrows();
} while (true); // should not report - body always terminates
}
public function doWhileVariableCondition(): void
{
$a = true;
do {
$this->alwaysThrows();
$a = false;
} while ($a); // should not report - body always terminates
}
public function neverReturnType(): never
{
throw new \Exception();
}
public function doWhileNeverReturnType(): void
{
do {
$this->neverReturnType();
} while (true); // already works - no error
}
public static function staticAlwaysThrows(): void
{
throw new \Exception();
}
public function doWhileStaticCall(): void
{
do {
self::staticAlwaysThrows();
} while (true); // should not report - body always terminates
}
}
function alwaysThrowsFunction(): void
{
throw new \Exception();
}
function doWhileFunctionCall(): void
{
do {
alwaysThrowsFunction();
} while (true); // should not report - body always terminates
}