1
0
Fork 0

Use property and constant values

pull/165/head
Felix Becker 2016-11-20 23:58:22 +01:00
parent 49b526d7e1
commit 4365fac0b0
1 changed files with 9 additions and 3 deletions

View File

@ -671,17 +671,23 @@ class DefinitionResolver
|| $node instanceof Node\Expr\AssignOp || $node instanceof Node\Expr\AssignOp
) { ) {
// Property, constant or variable // Property, constant or variable
// Use @var tag
if ( if (
($parent = $node->getAttribute('parentNode')) ($parent = $node->getAttribute('parentNode'))
&& ($docBlock = $parent->getAttribute('docBlock')) && ($docBlock = $parent->getAttribute('docBlock'))
&& !empty($varTags = $docBlock->getTagsByName('var')) && !empty($varTags = $docBlock->getTagsByName('var'))
&& ($type = $varTags[0]->getType()) && ($type = $varTags[0]->getType())
) { ) {
// Use @var tag
return $type; return $type;
} }
if ($node instanceof Node\Expr\Assign || $node instanceof Node\Expr\AssignOp) {
// Resolve the expression // Resolve the expression
if ($node instanceof Node\Stmt\PropertyProperty) {
if ($node->default) {
return $this->resolveExpressionNodeToType($node->default);
}
} else if ($node instanceof Node\Const_) {
return $this->resolveExpressionNodeToType($node->value);
} else if ($node instanceof Node\Expr\Assign || $node instanceof Node\Expr\AssignOp) {
return $this->resolveExpressionNodeToType($node); return $this->resolveExpressionNodeToType($node);
} }
// TODO: read @property tags of class // TODO: read @property tags of class