Skip to content

Commit 7815bcd

Browse files
committed
Closes #7330
1 parent 20ff21b commit 7815bcd

4 files changed

Lines changed: 5 additions & 6 deletions

File tree

rules/CodingStyle/Node/NameImporter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ private function addUseImport(
138138
FullyQualified $fullyQualified,
139139
FullyQualifiedObjectType $fullyQualifiedObjectType
140140
): void {
141-
if ($this->useNodesToAddCollector->hasImport($file, $fullyQualified, $fullyQualifiedObjectType)) {
141+
if ($this->useNodesToAddCollector->hasImport($file, $fullyQualifiedObjectType)) {
142142
return;
143143
}
144144

src/NodeTypeResolver/PhpDocNodeVisitor/NameImportingPhpDocNodeVisitor.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ private function processFqnNameImport(
146146
return null;
147147
}
148148

149-
if ($this->shouldImport($newNode, $identifierTypeNode, $fullyQualifiedObjectType)) {
149+
if ($this->shouldImport($file, $newNode, $identifierTypeNode, $fullyQualifiedObjectType)) {
150150
$this->useNodesToAddCollector->addUseImport($fullyQualifiedObjectType);
151151
$this->hasChanged = true;
152152

@@ -157,6 +157,7 @@ private function processFqnNameImport(
157157
}
158158

159159
private function shouldImport(
160+
File $file,
160161
IdentifierTypeNode $newNode,
161162
IdentifierTypeNode $identifierTypeNode,
162163
FullyQualifiedObjectType $fullyQualifiedObjectType
@@ -181,7 +182,7 @@ private function shouldImport(
181182

182183
$firstPath = Strings::before($identifierTypeNode->name, '\\' . $newNode->name);
183184
if ($firstPath === null) {
184-
return true;
185+
return ! $this->useNodesToAddCollector->hasImport($file, $fullyQualifiedObjectType);
185186
}
186187

187188
if ($firstPath === '') {

src/PostRector/Collector/UseNodesToAddCollector.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ public function getUseImportTypesByNode(File $file): array
8686

8787
public function hasImport(
8888
File $file,
89-
FullyQualified $fullyQualified,
9089
FullyQualifiedObjectType $fullyQualifiedObjectType
9190
): bool {
9291
$useImports = $this->getUseImportTypesByNode($file);

src/StaticTypeMapper/PhpDocParser/IdentifierPhpDocTypeMapper.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ public function mapIdentifierTypeNode(IdentifierTypeNode $identifierTypeNode, No
9797
return new UnionType($scalarTypes);
9898
}
9999

100-
$identifierTypeNode->name = ltrim($identifierTypeNode->name, '@');
101-
$objectType = new ObjectType($identifierTypeNode->name);
100+
$objectType = new ObjectType(ltrim($identifierTypeNode->name, '@'));
102101
}
103102

104103
$scope = $node->getAttribute(AttributeKey::SCOPE);

0 commit comments

Comments
 (0)