Skip to content

Commit

Permalink
[Performance][AutoImport] Remove just renamed check on ClassNameImpor…
Browse files Browse the repository at this point in the history
…tSkipper (#5106)
  • Loading branch information
samsonasik authored Oct 2, 2023
1 parent 478b257 commit dae8c61
Showing 1 changed file with 0 additions and 27 deletions.
27 changes: 0 additions & 27 deletions rules/CodingStyle/ClassNameImport/ClassNameImportSkipper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use PhpParser\Node\Stmt\Use_;
use PhpParser\Node\Stmt\UseUse;
use Rector\CodingStyle\Contract\ClassNameImport\ClassNameImportSkipVoterInterface;
use Rector\Core\Configuration\RenamedClassesDataCollector;
use Rector\Core\ValueObject\Application\File;
use Rector\Naming\Naming\UseImportsResolver;
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
Expand All @@ -23,7 +22,6 @@ final class ClassNameImportSkipper
*/
public function __construct(
private readonly iterable $classNameImportSkipVoters,
private readonly RenamedClassesDataCollector $renamedClassesDataCollector,
private readonly UseImportsResolver $useImportsResolver
) {
}
Expand Down Expand Up @@ -66,10 +64,6 @@ public function shouldImportName(Name $name, array $uses): bool
continue;
}

if ($this->isJustRenamedClass($stringName, $prefix, $useUse)) {
continue;
}

if ($this->isConflictedShortNameInUse($useUse, $useName, $lastUseName, $stringName)) {
return false;
}
Expand All @@ -93,25 +87,4 @@ private function isConflictedShortNameInUse(

return $useUse->alias instanceof Identifier && $useUse->alias->toString() === $stringName;
}

private function isJustRenamedClass(string $stringName, string $prefix, UseUse $useUse): bool
{
$useUseNameString = $prefix . $useUse->name->toString();

// is in renamed classes? skip it
foreach ($this->renamedClassesDataCollector->getOldToNewClasses() as $oldClass => $newClass) {
// is class being renamed in use imports?
if ($stringName !== $newClass) {
continue;
}

if ($useUseNameString !== $oldClass) {
continue;
}

return true;
}

return false;
}
}

0 comments on commit dae8c61

Please sign in to comment.