Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions rules/Naming/PropertyRenamer/PropertyPromotionRenamer.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ public function renamePropertyPromotion(Class_ $class): bool
return false;
}

$classReflection = $this->reflectionResolver->resolveClassReflection($class);
if (! $classReflection instanceof ClassReflection) {
return false;
}
// only needed for the trait usage check below; resolving it requires scope,
// which is missing right after another rule rewrote the class
$classReflection = $class->getTraitUses() === []
? null
: $this->reflectionResolver->resolveClassReflection($class);

// resolve possible and existing param names
$blockingParamNames = $this->resolveBlockingParamNames($constructClassMethod);
Expand Down Expand Up @@ -94,7 +95,10 @@ public function renamePropertyPromotion(Class_ $class): bool
continue;
}

if ($this->propertyManipulator->isUsedByTrait($classReflection, $currentParamName)) {
if ($classReflection instanceof ClassReflection && $this->propertyManipulator->isUsedByTrait(
$classReflection,
$currentParamName
)) {
continue;
}

Expand Down
Loading