-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
phpstan/phpstan-src
#3709Labels
Milestone
Description
Bug report
PHPStan is unable to infer the parameter count when argument unpacking is used.
Code snippet that reproduces the problem
In the following example the count() should specify the count of $ids as > 2. Unpacking the $ids array will result in 2 or more parameters.
function someFunc(bool $flag): array
{
$ids = [['fa', 'foo', 'baz']];
if ($flag) {
$ids[] = ['foo', 'bar', 'baz'];
}
if (count($ids) > 1) {
return array_intersect(...$ids);
}
return $ids[0];
}Function array_intersect invoked with 1 parameter, at least 2 required.
https://phpstan.org/r/9e875048-2e14-42de-b846-1dc04c67c0aa
This is a regression or new false positive in 0.12.33.
Expected output
count should be able to specify the parameter count when array unpacking is used.
Reactions are currently unavailable