Skip to content

Commit

Permalink
[AutoImport] Remove unused compare removed use on FullyQualifiedNameC…
Browse files Browse the repository at this point in the history
…lassNameImportSkipVoter (#5764)
  • Loading branch information
samsonasik committed Mar 23, 2024
1 parent e3e741e commit aac889b
Showing 1 changed file with 2 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use PhpParser\Node;
use Rector\CodingStyle\ClassNameImport\ShortNameResolver;
use Rector\CodingStyle\Contract\ClassNameImport\ClassNameImportSkipVoterInterface;
use Rector\Configuration\RenamedClassesDataCollector;
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
use Rector\ValueObject\Application\File;

Expand All @@ -24,8 +23,7 @@
final readonly class FullyQualifiedNameClassNameImportSkipVoter implements ClassNameImportSkipVoterInterface
{
public function __construct(
private ShortNameResolver $shortNameResolver,
private RenamedClassesDataCollector $renamedClassesDataCollector
private ShortNameResolver $shortNameResolver
) {
}

Expand All @@ -36,7 +34,6 @@ public function shouldSkip(File $file, FullyQualifiedObjectType $fullyQualifiedO
$shortNamesToFullyQualifiedNames = $this->shortNameResolver->resolveFromFile($file);
$fullyQualifiedObjectTypeShortName = $fullyQualifiedObjectType->getShortName();
$className = $fullyQualifiedObjectType->getClassName();
$removedUses = $this->renamedClassesDataCollector->getOldClasses();

foreach ($shortNamesToFullyQualifiedNames as $shortName => $fullyQualifiedName) {
if ($fullyQualifiedObjectTypeShortName !== $shortName) {
Expand All @@ -48,11 +45,7 @@ public function shouldSkip(File $file, FullyQualifiedObjectType $fullyQualifiedO
}

$fullyQualifiedName = ltrim($fullyQualifiedName, '\\');
if ($className === $fullyQualifiedName) {
return false;
}

return ! in_array($fullyQualifiedName, $removedUses, true);
return $className !== $fullyQualifiedName;
}

return false;
Expand Down

0 comments on commit aac889b

Please sign in to comment.