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

Prevent first-class-callable handling with FunctionDynamicStorageProvider

This commit is contained in:
adrew 2022-01-26 14:14:24 +03:00
parent de2257ecd3
commit e5dae6a901
3 changed files with 10 additions and 9 deletions

View File

@ -61,6 +61,10 @@ final class FunctionDynamicStorageProvider
Context $context,
CodeLocation $code_location
): ?FunctionStorage {
if ($stmt->isFirstClassCallable()) {
return null;
}
$dynamic_storage_id = strtolower($statements_analyzer->getFilePath())
. ':' . $stmt->getLine()
. ':' . (int)$stmt->getAttribute('startFilePos')

View File

@ -68,9 +68,12 @@ final class FunctionDynamicStorageProviderEvent
return $this->function_id;
}
public function getExpr(): PhpParser\Node\Expr\FuncCall
/**
* @return list<PhpParser\Node\Arg>
*/
public function getArgs(): array
{
return $this->func_call;
return $this->func_call->getArgs();
}
public function getContext(): Context

View File

@ -26,15 +26,9 @@ class CustomArrayMapStorageProvider implements FunctionDynamicStorageProviderInt
public static function getFunctionStorage(FunctionDynamicStorageProviderEvent $event): ?DynamicFunctionStorage
{
$func_call = $event->getExpr();
if ($func_call->isFirstClassCallable()) {
return null;
}
$template_provider = $event->getTemplateProvider();
$arg_type_inferer = $event->getArgTypeInferer();
$call_args = $func_call->getArgs();
$call_args = $event->getArgs();
$args_count = count($call_args);
$expected_callable_args_count = $args_count - 1;