1
0
Fork 0

Correct reference collection for New_ nodes

Closes #202
pull/189/head^2
Felix Becker 2016-12-13 02:40:39 +01:00
parent d90a88e625
commit b8a113ddd0
2 changed files with 2 additions and 8 deletions

View File

@ -2,7 +2,7 @@
namespace TestNamespace;
$obj = new TestClass();
$obj = new TestClass($a, $b, $c);
$obj->testMethod();
echo $obj->testProperty;
TestClass::staticTestMethod();

View File

@ -195,6 +195,7 @@ class DefinitionResolver
|| $parent instanceof Node\Namespace_
|| $parent instanceof Node\Param
|| $parent instanceof Node\FunctionLike
|| $parent instanceof Node\Expr\New_
|| $parent instanceof Node\Expr\StaticCall
|| $parent instanceof Node\Expr\ClassConstFetch
|| $parent instanceof Node\Expr\StaticPropertyFetch
@ -212,13 +213,6 @@ class DefinitionResolver
} else if ($grandParent instanceof Node\Stmt\Use_ && $grandParent->type === Node\Stmt\Use_::TYPE_FUNCTION) {
$name .= '()';
}
// Only the name node should be considered a reference, not the New_ node itself
} else if ($parent instanceof Node\Expr\New_) {
if (!($parent->class instanceof Node\Name)) {
// Cannot get definition of dynamic calls
return null;
}
$name = (string)$parent->class;
} else if ($node instanceof Node\Expr\MethodCall || $node instanceof Node\Expr\PropertyFetch) {
if ($node->name instanceof Node\Expr) {
// Cannot get definition if right-hand side is expression