99use PhpParser \Node \Expr \Array_ ;
1010use PhpParser \Node \Param ;
1111use PhpParser \Node \Scalar \String_ ;
12- use PhpParser \Node \Stmt \Class_ ;
1312use PhpParser \Node \Stmt \ClassLike ;
1413use PhpParser \Node \Stmt \ClassMethod ;
1514use PhpParser \Node \Stmt \Property ;
16- use PHPStan \Reflection \ReflectionProvider ;
1715use Rector \NodeNameResolver \NodeNameResolver ;
18- use Rector \Php81 \Enum \AttributeName ;
1916use Rector \PhpAttribute \Enum \DocTagNodeState ;
2017final class PhpAttributeAnalyzer
2118{
2219 /**
2320 * @readonly
2421 */
2522 private NodeNameResolver $ nodeNameResolver ;
26- /**
27- * @readonly
28- */
29- private ReflectionProvider $ reflectionProvider ;
30- public function __construct (NodeNameResolver $ nodeNameResolver , ReflectionProvider $ reflectionProvider )
23+ public function __construct (NodeNameResolver $ nodeNameResolver )
3124 {
3225 $ this ->nodeNameResolver = $ nodeNameResolver ;
33- $ this ->reflectionProvider = $ reflectionProvider ;
3426 }
3527 /**
3628 * @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Stmt\ClassLike|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Param $node
@@ -47,25 +39,6 @@ public function hasPhpAttribute($node, string $attributeClass): bool
4739 }
4840 return \false;
4941 }
50- /**
51- * @param AttributeName::* $attributeClass
52- */
53- public function hasInheritedPhpAttribute (Class_ $ class , string $ attributeClass ): bool
54- {
55- $ className = (string ) $ this ->nodeNameResolver ->getName ($ class );
56- if (!$ this ->reflectionProvider ->hasClass ($ className )) {
57- return \false;
58- }
59- $ classReflection = $ this ->reflectionProvider ->getClass ($ className );
60- $ ancestorClassReflections = array_merge ($ classReflection ->getParents (), $ classReflection ->getInterfaces ());
61- foreach ($ ancestorClassReflections as $ ancestorClassReflection ) {
62- $ nativeReflection = $ ancestorClassReflection ->getNativeReflection ();
63- if ((method_exists ($ nativeReflection , 'getAttributes ' ) ? $ nativeReflection ->getAttributes ($ attributeClass ) : []) !== []) {
64- return \true;
65- }
66- }
67- return \false;
68- }
6942 /**
7043 * @param string[] $attributeClasses
7144 * @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Stmt\ClassLike|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Param $node
0 commit comments