mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 12:55:26 +01:00
Merge pull request #7585 from tomasz-kusy/magic-const-fix
This commit is contained in:
commit
b06fb932d4
@ -16,6 +16,8 @@ use Psalm\Type\Atomic\TCallableString;
|
||||
use Psalm\Type\Atomic\TNonEmptyString;
|
||||
use Psalm\Type\Union;
|
||||
|
||||
use function dirname;
|
||||
|
||||
class MagicConstAnalyzer
|
||||
{
|
||||
public static function analyze(
|
||||
@ -84,10 +86,16 @@ class MagicConstAnalyzer
|
||||
} else {
|
||||
$statements_analyzer->node_data->setType($stmt, new Union([new TCallableString]));
|
||||
}
|
||||
} elseif ($stmt instanceof PhpParser\Node\Scalar\MagicConst\File
|
||||
|| $stmt instanceof PhpParser\Node\Scalar\MagicConst\Dir
|
||||
) {
|
||||
$statements_analyzer->node_data->setType($stmt, new Union([new TNonEmptyString()]));
|
||||
} elseif ($stmt instanceof PhpParser\Node\Scalar\MagicConst\Dir) {
|
||||
$statements_analyzer->node_data->setType(
|
||||
$stmt,
|
||||
Type::getString(dirname($statements_analyzer->getSource()->getFilePath()))
|
||||
);
|
||||
} elseif ($stmt instanceof PhpParser\Node\Scalar\MagicConst\File) {
|
||||
$statements_analyzer->node_data->setType(
|
||||
$stmt,
|
||||
Type::getString($statements_analyzer->getSource()->getFilePath())
|
||||
);
|
||||
} elseif ($stmt instanceof PhpParser\Node\Scalar\MagicConst\Trait_) {
|
||||
if ($statements_analyzer->getSource() instanceof TraitAnalyzer) {
|
||||
$statements_analyzer->node_data->setType($stmt, new Union([new TNonEmptyString()]));
|
||||
|
Loading…
Reference in New Issue
Block a user