From 21cee776248d36628beac7fec2f3a6204339fa2b Mon Sep 17 00:00:00 2001 From: Sara Itani Date: Mon, 10 Apr 2017 12:42:49 -0700 Subject: [PATCH] include traits and interfaces when retrieving fqn --- src/TolerantDefinitionResolver.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/TolerantDefinitionResolver.php b/src/TolerantDefinitionResolver.php index e42a629..0b538e2 100644 --- a/src/TolerantDefinitionResolver.php +++ b/src/TolerantDefinitionResolver.php @@ -1095,7 +1095,7 @@ class TolerantDefinitionResolver implements DefinitionResolverInterface // } else if ($node instanceof Tolerant\Node\MethodDeclaration) { // Class method: use ClassName->methodName() as name - $class = $node->getFirstAncestor(Tolerant\Node\Statement\ClassDeclaration::class); + $class = $node->getFirstAncestor(Tolerant\Node\Statement\ClassDeclaration::class, Tolerant\Node\Statement\TraitDeclaration::class, Tolerant\Node\Statement\InterfaceDeclaration::class); if (!isset($class->name)) { // Ignore anonymous classes return null; @@ -1116,7 +1116,9 @@ class TolerantDefinitionResolver implements DefinitionResolverInterface else if ( $node instanceof Tolerant\Node\Expression\Variable && ($propertyDeclaration = $node->getFirstAncestor(Tolerant\Node\PropertyDeclaration::class)) !== null && - ($classDeclaration = $node->getFirstAncestor(Tolerant\Node\Statement\ClassDeclaration::class)) !== null) + ($classDeclaration = + $node->getFirstAncestor(Tolerant\Node\Statement\ClassDeclaration::class, Tolerant\Node\Statement\InterfaceDeclaration::class, Tolerant\Node\Statement\TraitDeclaration::class) + ) !== null) { if ($propertyDeclaration->isStatic()) { // Static Property: use ClassName::$propertyName as name