mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
don't anonymize call to count to allow assertions on count to be retrieved
This commit is contained in:
parent
59d3d2aa31
commit
97a6abd823
@ -79,7 +79,8 @@ class MatchAnalyzer
|
||||
&& $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];
|
||||
|
@ -82,6 +82,22 @@ class MatchTest extends TestCase
|
||||
'ignored_issues' => [],
|
||||
'php_version' => '8.0'
|
||||
],
|
||||
'MatchWithCount' => [
|
||||
'code' => '<?php
|
||||
/**
|
||||
* @return non-empty-array
|
||||
*/
|
||||
function test(array $array): array
|
||||
{
|
||||
return match (\count($array)) {
|
||||
0 => throw new \InvalidArgumentException,
|
||||
default => $array,
|
||||
};
|
||||
}',
|
||||
'assertions' => [],
|
||||
'ignored_issues' => [],
|
||||
'php_version' => '8.1'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user