1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 13:51:54 +01:00

Ignore specific callables (callable-array, callable-string) in the HighOrderFunctionArgHandler

This commit is contained in:
andrew 2023-04-07 14:16:41 +03:00
parent 2f7a7178ca
commit d9ad8b420e

View File

@ -154,7 +154,7 @@ final class HighOrderFunctionArgHandler
StatementsAnalyzer $statements_analyzer,
FunctionLikeParameter $container_param
): ?HighOrderFunctionArgInfo {
if (!$container_param->type || !$container_param->type->hasCallableType()) {
if (!self::isSupported($container_param)) {
return null;
}
@ -281,6 +281,28 @@ final class HighOrderFunctionArgHandler
return null;
}
private static function isSupported(FunctionLikeParameter $container_param): bool
{
if (!$container_param->type || !$container_param->type->hasCallableType()) {
return false;
}
foreach ($container_param->type->getAtomicTypes() as $a) {
if (($a instanceof TClosure || $a instanceof TCallable) && !$a->params) {
return false;
}
if ($a instanceof Type\Atomic\TCallableArray ||
$a instanceof Type\Atomic\TCallableString ||
$a instanceof Type\Atomic\TCallableKeyedArray
) {
return false;
}
}
return true;
}
private static function fromLiteralString(
Union $constant,
StatementsAnalyzer $statements_analyzer