diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/MatchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/MatchAnalyzer.php index 1b302d42f00..9e5423ae2a0 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/MatchAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/MatchAnalyzer.php @@ -79,7 +79,8 @@ public static function analyze( && $stmt->cond->name instanceof PhpParser\Node\Name && ($stmt->cond->name->parts === ['get_class'] || $stmt->cond->name->parts === ['gettype'] - || $stmt->cond->name->parts === ['get_debug_type']) + || $stmt->cond->name->parts === ['get_debug_type'] + || $stmt->cond->name->parts === ['count']) && $stmt->cond->getArgs() ) { $first_arg = $stmt->cond->getArgs()[0]; diff --git a/tests/MatchTest.php b/tests/MatchTest.php index c8ecde0cca2..615b7f69c95 100644 --- a/tests/MatchTest.php +++ b/tests/MatchTest.php @@ -82,6 +82,22 @@ function foo(Foo $value): string { 'ignored_issues' => [], 'php_version' => '8.0' ], + 'MatchWithCount' => [ + 'code' => ' throw new \InvalidArgumentException, + default => $array, + }; + }', + 'assertions' => [], + 'ignored_issues' => [], + 'php_version' => '8.1' + ], ]; }