[NodeTypeResolver] Fixes #6065 Use existing NodeTypeResolver object on Auto Imports short name (#6069)

This commit is contained in:
Abdul Malik Ikhsan 2021-04-10 04:00:57 +07:00 committed by GitHub
parent 9be459dd76
commit 4d78e28f25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -112,7 +112,11 @@ final class NameImportingPhpDocNodeVisitor extends AbstractPhpDocNodeVisitor
// should skip because its already used
if ($this->useNodesToAddCollector->isShortImported($phpParserNode, $fullyQualifiedObjectType)) {
if ($this->useNodesToAddCollector->isImportShortable($phpParserNode, $fullyQualifiedObjectType)) {
return new IdentifierTypeNode($fullyQualifiedObjectType->getShortName());
$newNode = new IdentifierTypeNode($fullyQualifiedObjectType->getShortName());
if ($newNode->name !== $identifierTypeNode->name) {
return $newNode;
}
return $identifierTypeNode;
}
return $identifierTypeNode;
@ -120,7 +124,11 @@ final class NameImportingPhpDocNodeVisitor extends AbstractPhpDocNodeVisitor
$this->useNodesToAddCollector->addUseImport($phpParserNode, $fullyQualifiedObjectType);
return new IdentifierTypeNode($fullyQualifiedObjectType->getShortName());
$newNode = new IdentifierTypeNode($fullyQualifiedObjectType->getShortName());
if ($newNode->name !== $identifierTypeNode->name) {
return $newNode;
}
return $identifierTypeNode;
}
private function shouldSkipShortClassName(FullyQualifiedObjectType $fullyQualifiedObjectType): bool