diff --git a/tests/PHPStan/Rules/Comparison/MatchExpressionRuleTest.php b/tests/PHPStan/Rules/Comparison/MatchExpressionRuleTest.php index 0b47552de7..8bdcff5319 100644 --- a/tests/PHPStan/Rules/Comparison/MatchExpressionRuleTest.php +++ b/tests/PHPStan/Rules/Comparison/MatchExpressionRuleTest.php @@ -552,4 +552,13 @@ public function testBug11246(): void $this->analyse([__DIR__ . '/data/bug-11246.php'], []); } + public function testBug9879(): void + { + if (PHP_VERSION_ID < 80100) { + $this->markTestSkipped('Test requires PHP 8.1.'); + } + + $this->analyse([__DIR__ . '/data/bug-9879.php'], []); + } + } diff --git a/tests/PHPStan/Rules/Comparison/data/bug-9879.php b/tests/PHPStan/Rules/Comparison/data/bug-9879.php new file mode 100644 index 0000000000..3223872658 --- /dev/null +++ b/tests/PHPStan/Rules/Comparison/data/bug-9879.php @@ -0,0 +1,18 @@ += 8.1 + +namespace Bug9879; + +final class A { + public function test(): void + { + for($idx = 0; $idx < 6; $idx += 1) { + match($idx % 3) { + 0 => 1, + 1 => 2, + 2 => 0, + }; + } + + } + +}