1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Fix #3639 - allow coerced types to count when picking callmap options

This commit is contained in:
Brown 2020-06-22 20:24:34 -04:00
parent 1f86afece7
commit 9b860214d5
2 changed files with 20 additions and 2 deletions

View File

@ -169,13 +169,16 @@ class InternalCallMapHandler
}
}
$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;
}

View File

@ -1174,6 +1174,21 @@ class FunctionCallTest extends TestCase
);
}',
],
'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
/**