Skip to content

Commit f2f25ba

Browse files
committed
skip import
1 parent e396704 commit f2f25ba

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

rules/CodingStyle/Application/UseImportsAdder.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,29 @@ private function createUses(
194194
Use_::TYPE_FUNCTION => $functionUseImportTypes,
195195
];
196196

197+
$useNames = [];
197198
foreach ($importsMapping as $type => $importTypes) {
198199
foreach ($importTypes as $importType) {
199200
if ($namespaceName !== null && $this->isCurrentNamespace($namespaceName, $importType)) {
200201
continue;
201202
}
202203

204+
$use = $importType->getUseNode($type);
205+
$currentUse = current($use->uses);
206+
207+
if ($currentUse === false) {
208+
continue;
209+
}
210+
211+
$currentUseName = strtolower($currentUse->name->getLast());
212+
if (in_array($currentUseName, $useNames, true)) {
213+
continue;
214+
}
215+
216+
$useNames[] = $currentUseName;
217+
203218
// already imported in previous cycle
204-
$newUses[] = $importType->getUseNode($type);
219+
$newUses[] = $use;
205220
}
206221
}
207222

0 commit comments

Comments
 (0)