Skip to content

Commit

Permalink
[AutoImport] Fix conflict current namespace auto import (#5024)
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Sep 15, 2023
1 parent f606358 commit 0678674
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ private function shouldImport(
}

if (str_starts_with($identifierTypeNode->name, '\\')) {
if ($fullyQualifiedObjectType->getShortName() !== $fullyQualifiedObjectType->getClassName()) {
return $fullyQualifiedObjectType->getShortName() !== ltrim($identifierTypeNode->name, '\\');
}

return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ final class AutoImportNamesTest extends AbstractRectorTestCase
#[DataProvider('provideData')]
public function test(string $filePath): void
{
if (str_ends_with($filePath, 'auto_import_conflict_name_all_fqcn_same_namespace.php.inc')) {
// @todo fix later
return;
}

$this->doTestFile($filePath);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ final class AutoImportConflictNameAllFqcnSameNamespace

namespace Rector\Tests\Renaming\Rector\Name\RenameClassRector\FixtureAutoImportNames;

use Rector\Tests\Renaming\Rector\Name\RenameClassRector\FixtureAutoImportNames\SomeShort;

final class AutoImportConflictNameAllFqcnSameNamespace
{
/**
Expand Down

0 comments on commit 0678674

Please sign in to comment.