diff --git a/rules/CodingStyle/Rector/ClassMethod/MakeInheritedMethodVisibilitySameAsParentRector.php b/rules/CodingStyle/Rector/ClassMethod/MakeInheritedMethodVisibilitySameAsParentRector.php index 52f714342d9..46bde460714 100644 --- a/rules/CodingStyle/Rector/ClassMethod/MakeInheritedMethodVisibilitySameAsParentRector.php +++ b/rules/CodingStyle/Rector/ClassMethod/MakeInheritedMethodVisibilitySameAsParentRector.php @@ -106,9 +106,11 @@ public function refactor(Node $node): ?Node /** @var string $methodName */ $methodName = $this->getName($classMethod->name); - foreach ($interfaces as $interface) { - if ($interface->hasNativeMethod($methodName)) { - continue 2; + if ($classMethod->isPublic()) { + foreach ($interfaces as $interface) { + if ($interface->hasNativeMethod($methodName)) { + continue 2; + } } }