Skip to content

Commit

Permalink
[Php80] Remove AstResolver usage on PhpAttributeAnalyzer (#5111)
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Oct 4, 2023
1 parent 39e4f0a commit 4e56b7c
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions rules/Php80/NodeAnalyzer/PhpAttributeAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Property;
use PHPStan\Reflection\ReflectionProvider;
use Rector\Core\PhpParser\AstResolver;
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\PhpAttribute\Enum\DocTagNodeState;

final class PhpAttributeAnalyzer
{
public function __construct(
private readonly AstResolver $astResolver,
private readonly NodeNameResolver $nodeNameResolver,
private readonly ReflectionProvider $reflectionProvider,
) {
Expand Down Expand Up @@ -54,13 +52,8 @@ public function hasInheritedPhpAttribute(Class_ $class, string $attributeClass):
$ancestorClassReflections = array_merge($classReflection->getParents(), $classReflection->getInterfaces());

foreach ($ancestorClassReflections as $ancestorClassReflection) {
$resolvedClass = $this->astResolver->resolveClassFromClassReflection($ancestorClassReflection);

if (! $resolvedClass instanceof Class_) {
continue;
}

if ($this->hasPhpAttribute($resolvedClass, $attributeClass)) {
$nativeReflection = $ancestorClassReflection->getNativeReflection();
if ($nativeReflection->getAttributes($attributeClass) !== []) {
return true;
}
}
Expand Down

0 comments on commit 4e56b7c

Please sign in to comment.