Skip to content

Commit a26c556

Browse files
committed
fix: add the condition to fix bug 13029.
1 parent 7107c62 commit a26c556

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

src/Rules/Comparison/MatchExpressionRule.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ public function processNode(Node $node, Scope $scope): array
132132
!$remainingType instanceof NeverType
133133
&& !$this->isUnhandledMatchErrorCaught($node)
134134
&& !$this->hasUnhandledMatchErrorThrowsTag($scope)
135+
&& !$remainingType->isArray()->yes()
135136
) {
136137
$errors[] = RuleErrorBuilder::message(sprintf(
137138
'Match expression does not handle remaining %s: %s',

tests/PHPStan/Analyser/AnalyserIntegrationTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,6 +1609,12 @@ public function testBug12979(): void
16091609
$this->assertNoErrors($errors);
16101610
}
16111611

1612+
public function testBug13029(): void
1613+
{
1614+
$errors = $this->runAnalyse(__DIR__ . '/data/bug-13029.php');
1615+
$this->assertNoErrors($errors);
1616+
}
1617+
16121618
/**
16131619
* @param string[]|null $allAnalysedFiles
16141620
* @return Error[]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug13029;
4+
5+
/** @var bool **/
6+
$bool1 = true;
7+
/** @var bool **/
8+
$bool2 = false;
9+
10+
$x = match([$bool1, $bool2]) {
11+
[true, false], [true, true] => 1,
12+
[false, false] => 0,
13+
[false, true] => -1,
14+
};

0 commit comments

Comments
 (0)