mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Fix issue resolving namespaced constants
This commit is contained in:
parent
2636b194db
commit
226aa27686
@ -404,12 +404,14 @@ class DependencyFinderVisitor extends PhpParser\NodeVisitorAbstract implements P
|
||||
$const_type = StatementsChecker::getSimpleType($this->codebase, $const->value, $this->aliases)
|
||||
?: Type::getMixed();
|
||||
|
||||
$fq_const_name = Type::getFQCLNFromString($const->name->name, $this->aliases);
|
||||
|
||||
if ($this->codebase->register_stub_files || $this->codebase->register_autoload_files) {
|
||||
$this->codebase->addGlobalConstantType($const->name->name, $const_type);
|
||||
$this->codebase->addGlobalConstantType($fq_const_name, $const_type);
|
||||
}
|
||||
|
||||
$this->file_storage->constants[$const->name->name] = $const_type;
|
||||
$this->file_storage->declaring_constants[$const->name->name] = $this->file_path;
|
||||
$this->file_storage->constants[$fq_const_name] = $const_type;
|
||||
$this->file_storage->declaring_constants[$fq_const_name] = $this->file_path;
|
||||
}
|
||||
} elseif ($this->codebase->register_autoload_files && $node instanceof PhpParser\Node\Stmt\If_) {
|
||||
if ($node->cond instanceof PhpParser\Node\Expr\BooleanNot) {
|
||||
|
@ -146,7 +146,9 @@ class StubTest extends TestCase
|
||||
echo Foo\SystemClass::HELLO;
|
||||
|
||||
$b = $a->foo(5, "hello");
|
||||
$c = Foo\SystemClass::bar(5, "hello");'
|
||||
$c = Foo\SystemClass::bar(5, "hello");
|
||||
|
||||
echo Foo\BAR;'
|
||||
);
|
||||
|
||||
$this->analyzeFile($file_path, new Context());
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
namespace Foo;
|
||||
|
||||
const BAR = "bat";
|
||||
|
||||
class SystemClass {
|
||||
const HELLO = 'hello';
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user