Skip to content

Commit

Permalink
[Reflection] Remove usage on PrivatesAccessor on ClassReflectionAnaly…
Browse files Browse the repository at this point in the history
…zer (#5366)
  • Loading branch information
samsonasik committed Dec 17, 2023
1 parent 1dcebfe commit aa52c4e
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions src/Reflection/ClassReflectionAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,18 @@

namespace Rector\Core\Reflection;

use PHPStan\BetterReflection\Reflection\ReflectionClass;
use PHPStan\Reflection\ClassReflection;
use Rector\Core\Util\Reflection\PrivatesAccessor;
use ReflectionEnum;

final class ClassReflectionAnalyzer
{
public function __construct(
private readonly PrivatesAccessor $privatesAccessor
) {
}

public function resolveParentClassName(ClassReflection $classReflection): ?string
{
$nativeReflection = $classReflection->getNativeReflection();
if ($nativeReflection instanceof ReflectionEnum) {
return null;
}

$betterReflectionClass = $this->privatesAccessor->getPrivateProperty(
$nativeReflection,
'betterReflectionClass'
);
/** @var ReflectionClass $betterReflectionClass */
return $betterReflectionClass->getParentClassName();
return $nativeReflection->getParentClassName();
}
}

0 comments on commit aa52c4e

Please sign in to comment.