Skip to content

Commit

Permalink
[Php83] Early check private method in child before check parent on Ad…
Browse files Browse the repository at this point in the history
…dOverrideAttributeToOverriddenMethodsRector (#5622)

* [Php83] Early check private method in child before check parent on AddOverrideAttributeToOverriddenMethodsRector

* [Php83] Early check private method in child before check parent on AddOverrideAttributeToOverriddenMethodsRector
  • Loading branch information
samsonasik committed Feb 16, 2024
1 parent c4dd05e commit 39d9c32
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Rector\Tests\Php83\Rector\ClassMethod\AddOverrideAttributeToOverriddenMethodsRector\Fixture;

use Rector\Tests\Php83\Rector\ClassMethod\AddOverrideAttributeToOverriddenMethodsRector\Source\ExampleParentClass;

class SkipPrivateMethod extends ExampleParentClass
{
private function bar()
{
}
}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ private function processAddOverrideAttribute(Class_ $class, array $parentClassRe
continue;
}

if ($classMethod->isPrivate()) {
continue;
}

// ignore if it already uses the attribute
if ($this->phpAttributeAnalyzer->hasPhpAttribute($classMethod, 'Override')) {
continue;
Expand Down

0 comments on commit 39d9c32

Please sign in to comment.