Skip to content
Permalink
Browse files

Support __METHOD__ and __FUNCTION__ magic constants better

  • Loading branch information
muglug committed Nov 30, 2019
1 parent 227ea20 commit 2383945fb9dab1542ce27e80ac139078e8f0aec3
Showing with 9 additions and 2 deletions.
  1. +9 −2 src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php
@@ -187,11 +187,18 @@ public static function analyze(
}
$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());
}

0 comments on commit 2383945

Please sign in to comment.
You can’t perform that action at this time.