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:
parent
2f7a7178ca
commit
d9ad8b420e
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user