File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44
55namespace Rector \DeadCode \NodeAnalyzer ;
66
7+ use PhpParser \Node \Stmt \Expression ;
8+ use PhpParser \Node \Expr \StaticCall ;
79use PhpParser \Node \Stmt \ClassMethod ;
810use Rector \NodeNameResolver \NodeNameResolver ;
911
10- final class ParentClassAnalyzer
12+ final readonly class ParentClassAnalyzer
1113{
1214 public function __construct (
13- private readonly NodeNameResolver $ nodeNameResolver ,
15+ private NodeNameResolver $ nodeNameResolver ,
1416 ) {
1517
1618 }
@@ -28,12 +30,12 @@ public function hasParentCall(ClassMethod $classMethod): bool
2830 $ classMethodName = $ classMethod ->name ->name ;
2931
3032 foreach ($ classMethod ->stmts as $ stmt ) {
31- if (! $ stmt instanceof \ PhpParser \ Node \ Stmt \ Expression) {
33+ if (! $ stmt instanceof Expression) {
3234 continue ;
3335 }
3436
3537 $ expr = $ stmt ->expr ;
36- if (! $ expr instanceof \ PhpParser \ Node \ Expr \ StaticCall) {
38+ if (! $ expr instanceof StaticCall) {
3739 continue ;
3840 }
3941
Original file line number Diff line number Diff line change @@ -243,15 +243,8 @@ private function shouldSkipClassMethod(ClassMethod $classMethod): bool
243243 if ($ this ->phpAttributeAnalyzer ->hasPhpAttribute ($ classMethod , self ::OVERRIDE_CLASS )) {
244244 return true ;
245245 }
246-
247246 // skip test setup method override, as rather clutters the code than helps
248- if ($ this ->isName ($ classMethod , 'setUp ' )) {
249- if ($ this ->parentClassAnalyzer ->hasParentCall ($ classMethod )) {
250- return true ;
251- }
252- }
253-
254- return false ;
247+ return $ this ->isName ($ classMethod , 'setUp ' ) && $ this ->parentClassAnalyzer ->hasParentCall ($ classMethod );
255248 }
256249
257250 private function shouldSkipParentClassMethod (ClassReflection $ parentClassReflection , ClassMethod $ classMethod ): bool
You can’t perform that action at this time.
0 commit comments