Skip to content
Permalink
Browse files

Fix #2101 - use more accurate fallback when match isn’t found

  • Loading branch information...
muglug committed Sep 8, 2019
1 parent a032978 commit 6b52b84bee312dfa509a00e9fd5eea2d96508ea9
Showing with 17 additions and 1 deletion.
  1. +10 −0 src/Psalm/Internal/Codebase/CallMap.php
  2. +7 −1 tests/FunctionCallTest.php
@@ -77,6 +77,8 @@ public static function getMatchingCallableFromCallMapOptions(
return $callables[0];
}
$matching_param_count_callable = null;
foreach ($callables as $possible_callable) {
$possible_function_params = $possible_callable->params;
@@ -156,11 +158,19 @@ public static function getMatchingCallableFromCallMapOptions(
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 @@ function getOrderings(array $arr): int {
'<?php
$a = hrtime(true);
$b = hrtime();
/** @psalm-suppress InvalidArgument */
/** @psalm-suppress InvalidScalarArgument */
$c = hrtime(1);
$d = hrtime(false);',
'assertions' => [
@@ -1852,6 +1852,12 @@ function foo(int $a, string $b, bool $c) : array {
]
);',
],
'printrBadArg' => [
'<?php
/** @psalm-suppress InvalidScalarArgument */
$a = print_r([], 1);
echo $a;',
],
];
}

0 comments on commit 6b52b84

Please sign in to comment.
You can’t perform that action at this time.