Skip to content

Commit

Permalink
Fix #3639 - allow coerced types to count when picking callmap options
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Jun 23, 2020
1 parent 1f86afe commit 9b86021
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Psalm/Internal/Codebase/InternalCallMapHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,16 @@ public static function getMatchingCallableFromCallMapOptions(
}
}

$arg_result = new \Psalm\Internal\Analyzer\TypeComparisonResult();

if (TypeAnalyzer::isContainedBy(
$codebase,
$arg_type,
$param_type,
true,
true
)) {
true,
$arg_result
) || $arg_result->type_coerced) {
continue;
}

Expand Down
15 changes: 15 additions & 0 deletions tests/FunctionCallTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,21 @@ function (array $matches) : string {
);
}',
],
'pregReplaceCallbackWithArray' => [
'<?php
/**
* @param string[] $ids
* @psalm-suppress MissingClosureReturnType
* @psalm-suppress MixedArgumentTypeCoercion
*/
function(array $ids): array {
return \preg_replace_callback(
"",
fn (array $matches) => $matches[4],
$ids
);
};'
],
'compactDefinedVariable' => [
'<?php
/**
Expand Down

0 comments on commit 9b86021

Please sign in to comment.