Skip to content

Commit

Permalink
[Renaming] Handle docblock aliased rename on RenameClassRector (#6498)
Browse files Browse the repository at this point in the history
* [Renaming] Handle docblock aliased rename on RenameClassRector

* fix

* more test for short name
  • Loading branch information
samsonasik authored Nov 24, 2024
1 parent 3c42539 commit 2bd06e3
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

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

use Rector\Tests\Renaming\Rector\Name\RenameClassRector\Source\OldClass as OldSomeClass;

/** @var OldSomeClass $var */
$var = get();

?>
-----
<?php

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

use Rector\Tests\Renaming\Rector\Name\RenameClassRector\Source\OldClass as OldSomeClass;

/** @var \Rector\Tests\Renaming\Rector\Name\RenameClassRector\Source\NewClass $var */
$var = get();

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

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

use Rector\Tests\Renaming\Rector\Name\RenameClassRector\Source\OldClass;

/** @var OldClass $var */
$var = get2();

?>
-----
<?php

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

/** @var \Rector\Tests\Renaming\Rector\Name\RenameClassRector\Source\NewClass $var */
$var = get2();

?>
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Rector\PhpDocParser\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor;
use Rector\Renaming\Collector\RenamedNameCollector;
use Rector\StaticTypeMapper\StaticTypeMapper;
use Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType;
use Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType;

final class ClassRenamePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor
Expand Down Expand Up @@ -134,8 +135,8 @@ private function resolveNamespacedName(
return $name;
}

if ($staticType instanceof ShortenedObjectType) {
return $name;
if ($staticType instanceof ShortenedObjectType || $staticType instanceof AliasedObjectType) {
return $staticType->getFullyQualifiedName();
}

$uses = $this->useImportsResolver->resolve();
Expand Down

0 comments on commit 2bd06e3

Please sign in to comment.