Skip to content

Commit 57ac216

Browse files
committed
Updated Rector to commit ed6887072d32d36be5f9dbe8d911316f552da3c5
rectorphp/rector-src@ed68870 [Renaming] Handle rename conflict docblock name on RenameClassRector (#6504)
1 parent ec03b8f commit 57ac216

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

rules/Renaming/Rector/Name/RenameClassRector.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use PhpParser\Node\Stmt\ClassLike;
1010
use PhpParser\Node\Stmt\Expression;
1111
use PhpParser\Node\Stmt\If_;
12-
use PhpParser\Node\Stmt\Namespace_;
1312
use PhpParser\Node\Stmt\Property;
1413
use Rector\Configuration\RenamedClassesDataCollector;
1514
use Rector\Contract\Rector\ConfigurableRectorInterface;
@@ -73,7 +72,7 @@ public function getNodeTypes() : array
7372
return [FullyQualified::class, Property::class, FunctionLike::class, Expression::class, ClassLike::class, If_::class];
7473
}
7574
/**
76-
* @param FunctionLike|FullyQualified|ClassLike|Expression|Namespace_|Property|If_ $node
75+
* @param FunctionLike|FullyQualified|ClassLike|Expression|Property|If_ $node
7776
*/
7877
public function refactor(Node $node) : ?Node
7978
{

src/Application/VersionResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ final class VersionResolver
1919
* @api
2020
* @var string
2121
*/
22-
public const PACKAGE_VERSION = '24ab53c63097683f95fc0244abd9c61a975163b8';
22+
public const PACKAGE_VERSION = 'ed6887072d32d36be5f9dbe8d911316f552da3c5';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2024-11-24 18:57:48';
27+
public const RELEASE_DATE = '2024-11-24 20:03:45';
2828
/**
2929
* @var int
3030
*/

src/NodeTypeResolver/PhpDocNodeVisitor/ClassRenamePhpDocNodeVisitor.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,11 @@ public function enterNode(Node $node) : ?Node
7171
/** @var \PhpParser\Node $currentPhpNode */
7272
$currentPhpNode = $this->currentPhpNode;
7373
$identifier = clone $node;
74+
$identifierName = $identifier->name;
7475
$identifier->name = $this->resolveNamespacedName($identifier, $currentPhpNode, $node->name);
7576
$staticType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType($identifier, $currentPhpNode);
7677
// make sure to compare FQNs
77-
$objectType = $this->ensureFQCNObject($staticType);
78+
$objectType = $this->ensureFQCNObject($staticType, $identifierName);
7879
foreach ($this->oldToNewTypes as $oldToNewType) {
7980
/** @var ObjectType $oldType */
8081
$oldType = $oldToNewType->getOldType();
@@ -163,8 +164,11 @@ private function resolveNamefromUse(array $uses, string $name) : string
163164
/**
164165
* @return \PHPStan\Type\ObjectType|\PHPStan\Type\Type
165166
*/
166-
private function ensureFQCNObject(Type $type)
167+
private function ensureFQCNObject(Type $type, string $identiferName)
167168
{
169+
if ($type instanceof ShortenedObjectType && \strncmp($identiferName, '\\', \strlen('\\')) === 0) {
170+
return new ObjectType(\ltrim($identiferName, '\\'));
171+
}
168172
if ($type instanceof ShortenedObjectType || $type instanceof AliasedObjectType) {
169173
return new ObjectType($type->getFullyQualifiedName());
170174
}

0 commit comments

Comments
 (0)