Skip to content

Commit 2d862a7

Browse files
authored
[CodingStyle] Skip equal modifier on direct parent method compatible on MakeInheritedMethodVisibilitySameAsParentRector (#6406)
1 parent d246d27 commit 2d862a7

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace Rector\Tests\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector\Fixture;
4+
5+
use Rector\Tests\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector\Source\Father;
6+
7+
class SkipEqualDirectParent extends Father
8+
{
9+
public function run()
10+
{
11+
}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Rector\Tests\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector\Source;
6+
7+
class Father extends GrandFather
8+
{
9+
public function run()
10+
{
11+
}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Rector\Tests\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector\Source;
6+
7+
class GrandFather
8+
{
9+
protected function run()
10+
{
11+
}
12+
}

rules/CodingStyle/Rector/ClassMethod/MakeInheritedMethodVisibilitySameAsParentRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function refactor(Node $node): ?Node
123123
/** @var ReflectionMethod $parentReflectionMethod */
124124
$parentReflectionMethod = $nativeClassReflection->getMethod($methodName);
125125
if ($this->isClassMethodCompatibleWithParentReflectionMethod($classMethod, $parentReflectionMethod)) {
126-
continue;
126+
continue 2;
127127
}
128128

129129
$this->changeClassMethodVisibilityBasedOnReflectionMethod($classMethod, $parentReflectionMethod);

0 commit comments

Comments
 (0)