Skip to content

Commit

Permalink
Do not remove final modifier from private constructors (#1663)
Browse files Browse the repository at this point in the history
  • Loading branch information
simPod committed Jan 12, 2022
1 parent bbe0567 commit fd34e6c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Rector\Tests\Php80\Rector\ClassMethod\FinalPrivateToPrivateVisibilityRector\Fixture;

abstract class FinalPrivate
{
final private function __construct()
{
}
}

?>
-----
<?php

namespace Rector\Tests\Php80\Rector\ClassMethod\FinalPrivateToPrivateVisibilityRector\Fixture;

abstract class FinalPrivate
{
final private function __construct()
{
}
}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use PhpParser\Node;
use PhpParser\Node\Stmt\ClassMethod;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\ValueObject\MethodName;
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\Privatization\NodeManipulator\VisibilityManipulator;
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
Expand Down Expand Up @@ -81,6 +82,10 @@ private function shouldSkip(ClassMethod $classMethod): bool
return true;
}

if ($classMethod->name->toString() === MethodName::CONSTRUCT) {
return true;
}

return ! $classMethod->isPrivate();
}
}

0 comments on commit fd34e6c

Please sign in to comment.