Skip to content

Commit

Permalink
[Renaming] Prevent overly greed type resolving in RenamePropertyRector (
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Apr 28, 2023
1 parent 7d16e3d commit b3e2696
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions rules/Renaming/Rector/PropertyFetch/RenamePropertyRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,14 @@ private function processFromPropertyFetch(PropertyFetch $propertyFetch): ?Proper
continue;
}

if (! $nodeVarType instanceof Type) {
$nodeVarType = $this->nodeTypeResolver->getType($propertyFetch->var);
}

if ($nodeVarType instanceof ThisType && $class instanceof ClassLike) {
$this->renameProperty($class, $renamedProperty);
}
if ($class instanceof ClassLike) {
if (! $nodeVarType instanceof Type) {
$nodeVarType = $this->nodeTypeResolver->getType($propertyFetch->var);
}
if ($nodeVarType instanceof ThisType ) {
$this->renameProperty($class, $renamedProperty);
}
}

$propertyFetch->name = new Identifier($renamedProperty->getNewProperty());
return $propertyFetch;
Expand Down

0 comments on commit b3e2696

Please sign in to comment.