mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Fix #2101 - use more accurate fallback when match isn’t found
This commit is contained in:
parent
a032978a85
commit
6b52b84bee
@ -77,6 +77,8 @@ class CallMap
|
||||
return $callables[0];
|
||||
}
|
||||
|
||||
$matching_param_count_callable = null;
|
||||
|
||||
foreach ($callables as $possible_callable) {
|
||||
$possible_function_params = $possible_callable->params;
|
||||
|
||||
@ -156,11 +158,19 @@ class CallMap
|
||||
break;
|
||||
}
|
||||
|
||||
if (count($args) === count($possible_function_params)) {
|
||||
$matching_param_count_callable = $possible_callable;
|
||||
}
|
||||
|
||||
if ($all_args_match) {
|
||||
return $possible_callable;
|
||||
}
|
||||
}
|
||||
|
||||
if ($matching_param_count_callable) {
|
||||
return $matching_param_count_callable;
|
||||
}
|
||||
|
||||
// if we don't succeed in finding a match, set to the first possible and wait for issues below
|
||||
return $callables[0];
|
||||
}
|
||||
|
@ -1602,7 +1602,7 @@ class FunctionCallTest extends TestCase
|
||||
'<?php
|
||||
$a = hrtime(true);
|
||||
$b = hrtime();
|
||||
/** @psalm-suppress InvalidArgument */
|
||||
/** @psalm-suppress InvalidScalarArgument */
|
||||
$c = hrtime(1);
|
||||
$d = hrtime(false);',
|
||||
'assertions' => [
|
||||
@ -1852,6 +1852,12 @@ class FunctionCallTest extends TestCase
|
||||
]
|
||||
);',
|
||||
],
|
||||
'printrBadArg' => [
|
||||
'<?php
|
||||
/** @psalm-suppress InvalidScalarArgument */
|
||||
$a = print_r([], 1);
|
||||
echo $a;',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user