Skip to content

Commit ea28257

Browse files
Add tests
1 parent 535cebc commit ea28257

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

tests/PHPStan/Rules/Comparison/MatchExpressionRuleTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,14 @@ public function testBug11310(): void
454454
'Match arm comparison between int<1, max> and 0 is always false.',
455455
24,
456456
],
457+
[
458+
'Match arm comparison between int<1, 6>|int<8, 14> and 0 is always false.',
459+
49,
460+
],
461+
[
462+
'Match arm comparison between 1|2|3|4|5|6 and 0 is always false.',
463+
74,
464+
],
457465
]);
458466
}
459467

tests/PHPStan/Rules/Comparison/data/bug-11310.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,53 @@ function baz(int $i): void {
2626
default => 'default',
2727
};
2828
}
29+
30+
/** @param int<0, 5>|int<7, 13> $i */
31+
function foo2(int $i): void {
32+
echo match ($i++) {
33+
0 => 'zero',
34+
default => 'default',
35+
};
36+
}
37+
38+
/** @param int<0, 5>|int<7, 13> $i */
39+
function bar2(int $i): void {
40+
echo match ($i--) {
41+
0 => 'zero',
42+
default => 'default',
43+
};
44+
}
45+
46+
/** @param int<0, 5>|int<7, 13> $i */
47+
function baz2(int $i): void {
48+
echo match (++$i) {
49+
0 => 'zero',
50+
1 => 'one',
51+
default => 'default',
52+
};
53+
}
54+
55+
/** @param 0|1|2|3|4|5 $i */
56+
function foo3(int $i): void {
57+
echo match ($i++) {
58+
0 => 'zero',
59+
default => 'default',
60+
};
61+
}
62+
63+
/** @param 0|1|2|3|4|5 $i */
64+
function bar3(int $i): void {
65+
echo match ($i--) {
66+
0 => 'zero',
67+
default => 'default',
68+
};
69+
}
70+
71+
/** @param 0|1|2|3|4|5 $i */
72+
function baz3(int $i): void {
73+
echo match (++$i) {
74+
0 => 'zero',
75+
1 => 'one',
76+
default => 'default',
77+
};
78+
}

0 commit comments

Comments
 (0)