Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ private function processFqnNameImport(
FullyQualifiedObjectType $fullyQualifiedObjectType,
File $file
): ?IdentifierTypeNode {
$parentNode = $identifierTypeNode->getAttribute(PhpDocAttributeKey::PARENT);
if ($parentNode instanceof TemplateTagValueNode) {
// might break
return null;
}

if (str_starts_with($fullyQualifiedObjectType->getClassName(), '@')) {
$fullyQualifiedObjectType = new FullyQualifiedObjectType(ltrim(
$fullyQualifiedObjectType->getClassName(),
Expand All @@ -112,26 +118,13 @@ private function processFqnNameImport(
return null;
}

$parentNode = $identifierTypeNode->getAttribute(PhpDocAttributeKey::PARENT);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do this check earlier, as it is fast

if ($parentNode instanceof TemplateTagValueNode) {
// might break
return null;
}

$newNode = new IdentifierTypeNode($fullyQualifiedObjectType->getShortName());

// should skip because its already used
if ($this->useNodesToAddCollector->isShortImported($file, $fullyQualifiedObjectType)) {
if (! $this->useNodesToAddCollector->isImportShortable($file, $fullyQualifiedObjectType)) {
return null;
}

if ($this->shouldImport($newNode, $identifierTypeNode, $fullyQualifiedObjectType)) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the block deleted is identical to the one after the outer IF statement

$this->useNodesToAddCollector->addUseImport($fullyQualifiedObjectType);
return $newNode;
}

return null;
}

if ($this->shouldImport($newNode, $identifierTypeNode, $fullyQualifiedObjectType)) {
Expand Down