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

Support __METHOD__ and __FUNCTION__ magic constants better

This commit is contained in:
Matthew Brown 2019-11-29 22:47:20 -05:00
parent 227ea2042a
commit 2383945fb9

View File

@ -187,11 +187,18 @@ class ExpressionAnalyzer
}
$statements_analyzer->node_data->setType($stmt, Type::getString($namespace));
} elseif ($stmt instanceof PhpParser\Node\Scalar\MagicConst\Method
|| $stmt instanceof PhpParser\Node\Scalar\MagicConst\Function_
) {
$source = $statements_analyzer->getSource();
if ($source instanceof FunctionLikeAnalyzer) {
$statements_analyzer->node_data->setType($stmt, Type::getString($source->getMethodId()));
} else {
$statements_analyzer->node_data->setType($stmt, new Type\Union([new Type\Atomic\TCallableString]));
}
} elseif ($stmt instanceof PhpParser\Node\Scalar\MagicConst\File
|| $stmt instanceof PhpParser\Node\Scalar\MagicConst\Dir
|| $stmt instanceof PhpParser\Node\Scalar\MagicConst\Function_
|| $stmt instanceof PhpParser\Node\Scalar\MagicConst\Trait_
|| $stmt instanceof PhpParser\Node\Scalar\MagicConst\Method
) {
$statements_analyzer->node_data->setType($stmt, Type::getString());
}