support constants
parent
debda85ea3
commit
e63ee99b81
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace HELLO {
|
||||
|
||||
/**
|
||||
* Does something really cool!
|
||||
*/
|
||||
function world() {
|
||||
|
||||
}
|
||||
|
||||
\HELLO;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
define('HELLO', true);
|
||||
|
||||
HELLO;
|
||||
|
||||
HELLO\world();
|
||||
}
|
|
@ -882,6 +882,11 @@ class DefinitionResolver
|
|||
}
|
||||
return (string)$class->namespacedName . '::' . $node->name;
|
||||
}
|
||||
}
|
||||
} else if ($node instanceof Node\Expr\FuncCall && $node->name instanceof Node\Name && (string)$node->name === 'define') {
|
||||
if (!isset($node->args[0]) || !($node->args[0]->value instanceof Node\Scalar\String_)) {
|
||||
return null;
|
||||
}
|
||||
return (string)$node->args[0]->value->value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,13 +50,9 @@ class SymbolInformation
|
|||
{
|
||||
$parent = $node->getAttribute('parentNode');
|
||||
$symbol = new self;
|
||||
if ($node instanceof Node\Stmt\Class_) {
|
||||
if ($node instanceof Node\Stmt\Class_|| $node instanceof Node\Stmt\Trait_) {
|
||||
$symbol->kind = SymbolKind::CLASS_;
|
||||
} else if ($node instanceof Node\Stmt\Trait_) {
|
||||
$symbol->kind = SymbolKind::CLASS_;
|
||||
} else if ($node instanceof Node\Stmt\Interface_) {
|
||||
$symbol->kind = SymbolKind::INTERFACE;
|
||||
} else if ($node instanceof Node\Name && $parent instanceof Node\Stmt\Namespace_) {
|
||||
} else if ($node instanceof Node\Stmt\Interface_ || ($node instanceof Node\Name && $parent instanceof Node\Stmt\Namespace_)) {
|
||||
$symbol->kind = SymbolKind::NAMESPACE;
|
||||
} else if ($node instanceof Node\Stmt\Function_) {
|
||||
$symbol->kind = SymbolKind::FUNCTION;
|
||||
|
@ -86,6 +82,17 @@ class SymbolInformation
|
|||
$symbol->name = $node->var;
|
||||
} else if (isset($node->name)) {
|
||||
$symbol->name = (string)$node->name;
|
||||
} else if
|
||||
(
|
||||
$node instanceof Node\Expr\FuncCall
|
||||
&& $node->name instanceof Node\Name
|
||||
&& (string)$node->name === 'define'
|
||||
&& isset($node->args[0])
|
||||
&& $node->args[0]->value instanceof Node\Scalar\String_
|
||||
) {
|
||||
// constants with define()
|
||||
$symbol->kind = SymbolKind::CONSTANT;
|
||||
$symbol->name = (string)$node->args[0]->value->value;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue