forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbug-12597.php
More file actions
68 lines (54 loc) · 1.08 KB
/
bug-12597.php
File metadata and controls
68 lines (54 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
66
67
68
<?php declare(strict_types = 1);
namespace Bug12597;
class HelloWorld
{
private const TYPE_1 = 1;
private const TYPE_2 = 2;
public function test(int $type): void
{
if (in_array($type, [self::TYPE_1, self::TYPE_2], true)) {
$message = 'Hello!';
}
if ($type === self::TYPE_1) {
$this->message($message);
}
}
public function message(string $message): void {}
}
class HelloWorld2
{
public function test(mixed $type): void
{
if (is_int($type) || is_string($type)) {
$message = 'Hello!';
}
if (is_int($type)) {
$this->message($message);
}
}
public function message(string $message): void {}
}
class Foo {}
class Bar {}
class HelloWorld3
{
public function test(mixed $type): void
{
if (is_int($type) || is_object($type)) {
$message = 'Hello!';
}
if (is_int($type)) {
$this->message($message);
}
}
public function test2(mixed $type): void
{
if ($type instanceof Foo || $type instanceof Bar) {
$message = 'Hello!';
}
if ($type instanceof Foo) {
$this->message($message);
}
}
public function message(string $message): void {}
}