1010use PhpParser \Node \Stmt \Class_ ;
1111use PhpParser \Node \Stmt \ClassMethod ;
1212use PHPStan \PhpDocParser \Ast \PhpDoc \DeprecatedTagValueNode ;
13- use PHPStan \Reflection \ClassReflection ;
1413use Rector \BetterPhpDocParser \PhpDocInfo \PhpDocInfo ;
1514use Rector \BetterPhpDocParser \PhpDocInfo \PhpDocInfoFactory ;
1615use Rector \Configuration \Parameter \FeatureFlags ;
@@ -176,12 +175,7 @@ private function shouldSkipClassMethod(Class_ $class, ClassMethod $classMethod):
176175 return true ;
177176 }
178177
179- $ classReflection = $ scope ->getClassReflection ();
180- if (! $ classReflection instanceof ClassReflection) {
181- return false ;
182- }
183-
184- return $ this ->isAttributeMarkerConstructor ($ classMethod , $ classReflection );
178+ return $ this ->isAttributeMarkerConstructor ($ classMethod , $ class );
185179 }
186180
187181 private function hasDeprecatedAnnotation (ClassMethod $ classMethod ): bool
@@ -197,16 +191,29 @@ private function hasDeprecatedAnnotation(ClassMethod $classMethod): bool
197191 /**
198192 * Skip constructor in attributes as might be a marker parameter
199193 */
200- private function isAttributeMarkerConstructor (ClassMethod $ classMethod , ClassReflection $ classReflection ): bool
194+ private function isAttributeMarkerConstructor (ClassMethod $ classMethod , Class_ $ class ): bool
201195 {
202196 if (! $ this ->isName ($ classMethod , MethodName::CONSTRUCT )) {
203197 return false ;
204198 }
205199
206- if (! $ classReflection ->isAttributeClass ()) {
200+ if (! $ this ->isAttributeClass ($ class )) {
207201 return false ;
208202 }
209203
210204 return $ classMethod ->getDocComment () instanceof Doc;
211205 }
206+
207+ private function isAttributeClass (Class_ $ class ): bool
208+ {
209+ foreach ($ class ->attrGroups as $ attrGroup ) {
210+ foreach ($ attrGroup ->attrs as $ attr ) {
211+ if ($ this ->isName ($ attr ->name , 'Attribute ' )) {
212+ return true ;
213+ }
214+ }
215+ }
216+
217+ return false ;
218+ }
212219}
0 commit comments