1
0
Fork 0

fix property / constant ancestor check

pull/357/head
Sara Itani 2017-04-10 13:13:47 -07:00
parent 21cee77624
commit b02c164c2b
1 changed files with 15 additions and 3 deletions

View File

@ -1095,7 +1095,11 @@ class TolerantDefinitionResolver implements DefinitionResolverInterface
// } // }
else if ($node instanceof Tolerant\Node\MethodDeclaration) { else if ($node instanceof Tolerant\Node\MethodDeclaration) {
// Class method: use ClassName->methodName() as name // Class method: use ClassName->methodName() as name
$class = $node->getFirstAncestor(Tolerant\Node\Statement\ClassDeclaration::class, Tolerant\Node\Statement\TraitDeclaration::class, Tolerant\Node\Statement\InterfaceDeclaration::class); $class = $node->getFirstAncestor(
Tolerant\Node\Statement\ClassDeclaration::class,
Tolerant\Node\Statement\InterfaceDeclaration::class,
Tolerant\Node\Statement\TraitDeclaration::class
);
if (!isset($class->name)) { if (!isset($class->name)) {
// Ignore anonymous classes // Ignore anonymous classes
return null; return null;
@ -1117,7 +1121,11 @@ class TolerantDefinitionResolver implements DefinitionResolverInterface
$node instanceof Tolerant\Node\Expression\Variable && $node instanceof Tolerant\Node\Expression\Variable &&
($propertyDeclaration = $node->getFirstAncestor(Tolerant\Node\PropertyDeclaration::class)) !== null && ($propertyDeclaration = $node->getFirstAncestor(Tolerant\Node\PropertyDeclaration::class)) !== null &&
($classDeclaration = ($classDeclaration =
$node->getFirstAncestor(Tolerant\Node\Statement\ClassDeclaration::class, Tolerant\Node\Statement\InterfaceDeclaration::class, Tolerant\Node\Statement\TraitDeclaration::class) $node->getFirstAncestor(
Tolerant\Node\Statement\ClassDeclaration::class,
Tolerant\Node\Statement\InterfaceDeclaration::class,
Tolerant\Node\Statement\TraitDeclaration::class
)
) !== null) ) !== null)
{ {
if ($propertyDeclaration->isStatic()) { if ($propertyDeclaration->isStatic()) {
@ -1143,7 +1151,11 @@ class TolerantDefinitionResolver implements DefinitionResolverInterface
} }
if ($constDeclaration instanceof Tolerant\Node\ClassConstDeclaration) { if ($constDeclaration instanceof Tolerant\Node\ClassConstDeclaration) {
// Class constant: use ClassName::CONSTANT_NAME as name // Class constant: use ClassName::CONSTANT_NAME as name
$classDeclaration = $constDeclaration->getFirstAncestor(Tolerant\Node\Statement\ClassDeclaration::class); $classDeclaration = $constDeclaration->getFirstAncestor(
Tolerant\Node\Statement\ClassDeclaration::class,
Tolerant\Node\Statement\InterfaceDeclaration::class,
Tolerant\Node\Statement\TraitDeclaration::class
);
if (!isset($classDeclaration->name)) { if (!isset($classDeclaration->name)) {
return null; return null;
} }