diff --git a/rules-tests/CodingStyle/Rector/ClassMethod/MakeInheritedMethodVisibilitySameAsParentRector/Fixture/private.php.inc b/rules-tests/CodingStyle/Rector/ClassMethod/MakeInheritedMethodVisibilitySameAsParentRector/Fixture/private.php.inc deleted file mode 100644 index 3d9a0d039da..00000000000 --- a/rules-tests/CodingStyle/Rector/ClassMethod/MakeInheritedMethodVisibilitySameAsParentRector/Fixture/private.php.inc +++ /dev/null @@ -1,39 +0,0 @@ - ------ - diff --git a/rules-tests/CodingStyle/Rector/ClassMethod/MakeInheritedMethodVisibilitySameAsParentRector/Fixture/skip_private_parent_method.php.inc b/rules-tests/CodingStyle/Rector/ClassMethod/MakeInheritedMethodVisibilitySameAsParentRector/Fixture/skip_private_parent_method.php.inc new file mode 100644 index 00000000000..a67231da06a --- /dev/null +++ b/rules-tests/CodingStyle/Rector/ClassMethod/MakeInheritedMethodVisibilitySameAsParentRector/Fixture/skip_private_parent_method.php.inc @@ -0,0 +1,17 @@ +getMethod($methodName); + + // private methods are not inherited, so the child method does not override them + // and its visibility must not be aligned to them + if ($parentReflectionMethod->isPrivate()) { + continue; + } + if ($this->isClassMethodCompatibleWithParentReflectionMethod($classMethod, $parentReflectionMethod)) { continue 2; } @@ -146,15 +153,7 @@ private function isClassMethodCompatibleWithParentReflectionMethod( return true; } - if ($reflectionMethod->isProtected() && $classMethod->isProtected()) { - return true; - } - - if (! $reflectionMethod->isPrivate()) { - return false; - } - - return $classMethod->isPrivate(); + return $reflectionMethod->isProtected() && $classMethod->isProtected(); } private function changeClassMethodVisibilityBasedOnReflectionMethod( @@ -168,11 +167,6 @@ private function changeClassMethodVisibilityBasedOnReflectionMethod( if ($reflectionMethod->isProtected()) { $this->visibilityManipulator->makeProtected($classMethod); - return; - } - - if ($reflectionMethod->isPrivate()) { - $this->visibilityManipulator->makePrivate($classMethod); } } }