Skip to content

Commit ccb3f43

Browse files
authored
[perf] Skip reflection in MakeInheritedMethodVisibilitySameAsParentRector when no parent or no methods (#8580)
1 parent b99f9dc commit ccb3f43

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎rules/CodingStyle/Rector/ClassMethod/MakeInheritedMethodVisibilitySameAsParentRector.php‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Rector\CodingStyle\Rector\ClassMethod;
66

77
use PhpParser\Node;
8+
use PhpParser\Node\Name;
89
use PhpParser\Node\Stmt\Class_;
910
use PhpParser\Node\Stmt\ClassMethod;
1011
use PHPStan\Reflection\ClassReflection;
@@ -82,6 +83,15 @@ public function refactor(Node $node): ?Node
8283
return null;
8384
}
8485

86+
// no parent class to align visibility to
87+
if (! $node->extends instanceof Name) {
88+
return null;
89+
}
90+
91+
if ($node->getMethods() === []) {
92+
return null;
93+
}
94+
8595
$classReflection = $this->reflectionResolver->resolveClassReflection($node);
8696
if (! $classReflection instanceof ClassReflection) {
8797
return null;

0 commit comments

Comments
 (0)