From 219c018ab2756d8d16678806e33b092f35f0566a Mon Sep 17 00:00:00 2001 From: Sara Itani Date: Mon, 10 Apr 2017 21:58:08 -0700 Subject: [PATCH] Disclude anonymous class members from definitions --- src/TolerantDefinitionResolver.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/TolerantDefinitionResolver.php b/src/TolerantDefinitionResolver.php index 2577bd3..820d5b2 100644 --- a/src/TolerantDefinitionResolver.php +++ b/src/TolerantDefinitionResolver.php @@ -1096,6 +1096,7 @@ class TolerantDefinitionResolver implements DefinitionResolverInterface else if ($node instanceof Tolerant\Node\MethodDeclaration) { // Class method: use ClassName->methodName() as name $class = $node->getFirstAncestor( + Tolerant\Node\Expression\ObjectCreationExpression::class, Tolerant\Node\Statement\ClassDeclaration::class, Tolerant\Node\Statement\InterfaceDeclaration::class, Tolerant\Node\Statement\TraitDeclaration::class @@ -1122,11 +1123,12 @@ class TolerantDefinitionResolver implements DefinitionResolverInterface ($propertyDeclaration = $node->getFirstAncestor(Tolerant\Node\PropertyDeclaration::class)) !== null && ($classDeclaration = $node->getFirstAncestor( + Tolerant\Node\Statement\ObjectCreationExpression::class, Tolerant\Node\Statement\ClassDeclaration::class, Tolerant\Node\Statement\InterfaceDeclaration::class, Tolerant\Node\Statement\TraitDeclaration::class ) - ) !== null) + ) !== null && !($classDeclaration instanceof Tolerant\Node\Statement\ObjectCreationExpression)) { if ($propertyDeclaration->isStatic()) { // Static Property: use ClassName::$propertyName as name