Removes final from methods where possible.
Risky when child class overrides a private method.
Private methods of non-final classes must not be declared final.
Allowed types: bool
Default value: true
Default configuration.
--- Original
+++ New
<?php
final class Foo
{
- final public function foo1() {}
- final protected function bar() {}
- final private function baz() {}
+ public function foo1() {}
+ protected function bar() {}
+ private function baz() {}
}
class Bar
{
- final private function bar1() {}
+ private function bar1() {}
}With configuration: ['private_methods' => false].
--- Original
+++ New
<?php
final class Foo
{
- final private function baz() {}
+ private function baz() {}
}
class Bar
{
final private function bar1() {}
}The rule is part of the following rule sets:
- Fixer class: PhpCsFixer\Fixer\ClassNotation\NoUnneededFinalMethodFixer
- Test class: PhpCsFixer\Tests\Fixer\ClassNotation\NoUnneededFinalMethodFixerTest
The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.