Skip to content

Commit

Permalink
[Reflection] Remove parent lookup on ReflectionResolver (#4169)
Browse files Browse the repository at this point in the history
* [Reflection] Remove parent lookup on ReflectionResolver

* increase kernel cache key
  • Loading branch information
samsonasik committed Jun 11, 2023
1 parent d541d1a commit ea2ee12
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Kernel/RectorKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ final class RectorKernel
/**
* @var string
*/
private const CACHE_KEY = 'v89';
private const CACHE_KEY = 'v90';

private ContainerInterface|null $container = null;

Expand Down
12 changes: 3 additions & 9 deletions src/Reflection/ReflectionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
use Rector\Core\Exception\ShouldNotHappenException;
use Rector\Core\NodeAnalyzer\ClassAnalyzer;
use Rector\Core\PhpParser\AstResolver;
use Rector\Core\PhpParser\Node\BetterNodeFinder;
use Rector\Core\PHPStan\Reflection\TypeToCallReflectionResolver\TypeToCallReflectionResolverRegistry;
use Rector\Core\ValueObject\MethodName;
use Rector\NodeNameResolver\NodeNameResolver;
Expand All @@ -41,7 +40,6 @@ final class ReflectionResolver

public function __construct(
private readonly ReflectionProvider $reflectionProvider,
private readonly BetterNodeFinder $betterNodeFinder,
private readonly NodeTypeResolver $nodeTypeResolver,
private readonly NodeNameResolver $nodeNameResolver,
private readonly TypeToCallReflectionResolverRegistry $typeToCallReflectionResolverRegistry,
Expand Down Expand Up @@ -195,16 +193,12 @@ public function resolveFunctionLikeReflectionFromCall(

public function resolveMethodReflectionFromClassMethod(ClassMethod $classMethod): ?MethodReflection
{
$classLike = $this->betterNodeFinder->findParentType($classMethod, ClassLike::class);
if (! $classLike instanceof ClassLike) {
return null;
}

$className = $this->nodeNameResolver->getName($classLike);
if (! is_string($className)) {
$classReflection = $this->resolveClassReflection($classMethod);
if (! $classReflection instanceof ClassReflection) {
return null;
}

$className = $classReflection->getName();
$methodName = $this->nodeNameResolver->getName($classMethod);
$scope = $classMethod->getAttribute(AttributeKey::SCOPE);

Expand Down

0 comments on commit ea2ee12

Please sign in to comment.