1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Prevent variadic args disrupting required closure param count

This commit is contained in:
Matthew Brown 2018-03-21 09:04:07 -04:00
parent 9404de699d
commit 49820b06dd
2 changed files with 10 additions and 1 deletions

View File

@ -1045,7 +1045,7 @@ class CallChecker
$required_param_count = 0;
foreach ($closure_params as $i => $param) {
if (!$param->is_optional) {
if (!$param->is_optional && !$param->is_variadic) {
$required_param_count = $i + 1;
}
}

View File

@ -269,6 +269,15 @@ class CallableTest extends TestCase
callMeMaybe("foo");',
],
'arrayMapVariadicClosureArg' => [
'<?php
$a = array_map(
function(int $type, string ...$args):string {
return "hello";
},
[1, 2, 3]
);',
],
];
}