1
0
Fork 0

refactor: use ClassLike interface (#506)

pull/508/head
Jens Hausdorf 2017-10-28 21:27:32 +02:00 committed by Felix Becker
parent 1db6b7bbb3
commit fbaa7b3cc5
1 changed files with 5 additions and 15 deletions

View File

@ -182,9 +182,7 @@ class DefinitionResolver
// Interfaces, classes, traits, namespaces, functions, and global const elements // Interfaces, classes, traits, namespaces, functions, and global const elements
$def->isGlobal = ( $def->isGlobal = (
$node instanceof Node\Statement\InterfaceDeclaration || $node instanceof PhpParser\ClassLike ||
$node instanceof Node\Statement\ClassDeclaration ||
$node instanceof Node\Statement\TraitDeclaration ||
($node instanceof Node\Statement\NamespaceDefinition && $node->name !== null) || ($node instanceof Node\Statement\NamespaceDefinition && $node->name !== null) ||
@ -1101,9 +1099,7 @@ class DefinitionResolver
// interface C { } A\B\C // interface C { } A\B\C
// trait C { } A\B\C // trait C { } A\B\C
if ( if (
$node instanceof Node\Statement\ClassDeclaration || $node instanceof PhpParser\ClassLike
$node instanceof Node\Statement\InterfaceDeclaration ||
$node instanceof Node\Statement\TraitDeclaration
) { ) {
return (string) $node->getNamespacedName(); return (string) $node->getNamespacedName();
} }
@ -1134,9 +1130,7 @@ class DefinitionResolver
// Class method: use ClassName->methodName() as name // Class method: use ClassName->methodName() as name
$class = $node->getFirstAncestor( $class = $node->getFirstAncestor(
Node\Expression\ObjectCreationExpression::class, Node\Expression\ObjectCreationExpression::class,
Node\Statement\ClassDeclaration::class, PhpParser\ClassLike::class
Node\Statement\InterfaceDeclaration::class,
Node\Statement\TraitDeclaration::class
); );
if (!isset($class->name)) { if (!isset($class->name)) {
// Ignore anonymous classes // Ignore anonymous classes
@ -1160,9 +1154,7 @@ class DefinitionResolver
($classDeclaration = ($classDeclaration =
$node->getFirstAncestor( $node->getFirstAncestor(
Node\Expression\ObjectCreationExpression::class, Node\Expression\ObjectCreationExpression::class,
Node\Statement\ClassDeclaration::class, PhpParser\ClassLike::class
Node\Statement\InterfaceDeclaration::class,
Node\Statement\TraitDeclaration::class
) )
) !== null && isset($classDeclaration->name)) { ) !== null && isset($classDeclaration->name)) {
$name = $node->getName(); $name = $node->getName();
@ -1190,9 +1182,7 @@ class DefinitionResolver
// Class constant: use ClassName::CONSTANT_NAME as name // Class constant: use ClassName::CONSTANT_NAME as name
$classDeclaration = $constDeclaration->getFirstAncestor( $classDeclaration = $constDeclaration->getFirstAncestor(
Node\Expression\ObjectCreationExpression::class, Node\Expression\ObjectCreationExpression::class,
Node\Statement\ClassDeclaration::class, PhpParser\ClassLike::class
Node\Statement\InterfaceDeclaration::class,
Node\Statement\TraitDeclaration::class
); );
if (!isset($classDeclaration->name)) { if (!isset($classDeclaration->name)) {