mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix #1555 - allow phantom class constants
This commit is contained in:
parent
520b646ef6
commit
aea33824e6
@ -145,7 +145,9 @@ class StaticCallAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\
|
||||
}
|
||||
}
|
||||
|
||||
if (!$does_class_exist) {
|
||||
if (!isset($context->phantom_classes[strtolower($fq_class_name)])
|
||||
&& !$does_class_exist
|
||||
) {
|
||||
$does_class_exist = ClassLikeAnalyzer::checkFullyQualifiedClassLikeName(
|
||||
$statements_analyzer,
|
||||
$fq_class_name,
|
||||
|
@ -74,7 +74,9 @@ class ClassConstFetchAnalyzer
|
||||
);
|
||||
|
||||
if ($stmt->name instanceof PhpParser\Node\Identifier) {
|
||||
if (!$context->inside_class_exists || $stmt->name->name !== 'class') {
|
||||
if ((!$context->inside_class_exists || $stmt->name->name !== 'class')
|
||||
&& !isset($context->phantom_classes[strtolower($fq_class_name)])
|
||||
) {
|
||||
if (ClassLikeAnalyzer::checkFullyQualifiedClassLikeName(
|
||||
$statements_analyzer,
|
||||
$fq_class_name,
|
||||
|
@ -513,6 +513,18 @@ class ClassTest extends TestCase
|
||||
}
|
||||
}',
|
||||
],
|
||||
'noErrorsAfterClassExists' => [
|
||||
'<?php
|
||||
if (class_exists(A::class)) {
|
||||
if (method_exists(A::class, "method")) {
|
||||
echo A::method();
|
||||
}
|
||||
|
||||
echo A::class;
|
||||
/** @psalm-suppress MixedArgument */
|
||||
echo A::SOME_CONST;
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user