1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 12:55:26 +01:00

fix a weird case

This commit is contained in:
orklah 2022-01-22 17:45:40 +01:00
parent 997d5d5f5f
commit 73af019110

View File

@ -227,30 +227,32 @@ class AtomicStaticCallAnalyzer
if ($stmt->isFirstClassCallable()) {
$return_type_candidate = null;
$method_name_type = $statements_analyzer->node_data->getType($stmt->name);
if ($method_name_type && $method_name_type->isSingleStringLiteral()) {
$method_identifier = new MethodIdentifier(
$fq_class_name,
strtolower($method_name_type->getSingleStringLiteral()->value)
);
//the call to methodExists will register that the method was called from somewhere
if ($codebase->methods->methodExists(
$method_identifier,
$context->calling_method_id,
null,
$statements_analyzer,
$statements_analyzer->getFilePath(),
true,
$context->insideUse()
)) {
$method_storage = $codebase->methods->getStorage($method_identifier);
if (!$stmt->name instanceof PhpParser\Node\Identifier) {
$method_name_type = $statements_analyzer->node_data->getType($stmt->name);
if ($method_name_type && $method_name_type->isSingleStringLiteral()) {
$method_identifier = new MethodIdentifier(
$fq_class_name,
strtolower($method_name_type->getSingleStringLiteral()->value)
);
//the call to methodExists will register that the method was called from somewhere
if ($codebase->methods->methodExists(
$method_identifier,
$context->calling_method_id,
null,
$statements_analyzer,
$statements_analyzer->getFilePath(),
true,
$context->insideUse()
)) {
$method_storage = $codebase->methods->getStorage($method_identifier);
$return_type_candidate = new Union([new TClosure(
'Closure',
$method_storage->params,
$method_storage->return_type,
$method_storage->pure
)]);
$return_type_candidate = new Union([new TClosure(
'Closure',
$method_storage->params,
$method_storage->return_type,
$method_storage->pure
)]);
}
}
}