mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Fix const reference in current context
This commit is contained in:
parent
472cdf6bea
commit
fb9e9bea32
@ -34,6 +34,7 @@ class ConstFetchAnalyzer
|
||||
Context $context
|
||||
) {
|
||||
$const_name = implode('\\', $stmt->name->parts);
|
||||
|
||||
switch (strtolower($const_name)) {
|
||||
case 'null':
|
||||
$stmt->inferredType = Type::getNull();
|
||||
|
@ -1354,8 +1354,8 @@ class StatementsAnalyzer extends SourceAnalyzer implements StatementsSource
|
||||
}
|
||||
}
|
||||
|
||||
if ($context->hasVariable($const_name, $statements_analyzer)) {
|
||||
return $context->vars_in_scope[$const_name];
|
||||
if ($context->hasVariable($fq_const_name, $this)) {
|
||||
return $context->vars_in_scope[$fq_const_name];
|
||||
}
|
||||
|
||||
$file_path = $statements_analyzer->getRootFilePath();
|
||||
|
@ -374,6 +374,13 @@ class ConstantTest extends TestCase
|
||||
echo ns2\cons2;
|
||||
}',
|
||||
],
|
||||
'allowConstantToBeDefinedInNamespaceNadReferenced' => [
|
||||
'<?php
|
||||
namespace ns;
|
||||
function func(): void {}
|
||||
define(__NAMESPACE__."\\cons", 0);
|
||||
cons;'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user