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:
parent
227ea2042a
commit
2383945fb9
@ -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());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user