Internal classes should be final
.
Changing classes to final
might cause code execution to break.
Warning
This option is deprecated and will be removed in the next major version. Use exclude
to configure PHPDoc annotations tags and attributes.
Class level attribute or annotation tags that must be omitted to fix the class, even if all of the white list ones are used as well (case insensitive).
Allowed types: list<string>
Default value: ['@final', '@Entity', '@ORM\\Entity', '@ORM\\Mapping\\Entity', '@Mapping\\Entity', '@Document', '@ODM\\Document']
Warning
This option is deprecated and will be removed in the next major version. Use include
to configure PHPDoc annotations tags and attributes.
Class level attribute or annotation tags that must be set in order to fix the class (case insensitive).
Allowed types: list<string>
Default value: ['@internal']
Whether classes without any DocBlock should be fixed to final.
Allowed types: bool
Default value: false
Class level attribute or annotation tags that must be omitted to fix the class, even if all of the white list ones are used as well (case insensitive).
Allowed types: list<string>
Default value: ['final', 'Entity', 'ORM\\Entity', 'ORM\\Mapping\\Entity', 'Mapping\\Entity', 'Document', 'ODM\\Document']
Class level attribute or annotation tags that must be set in order to fix the class (case insensitive).
Allowed types: list<string>
Default value: ['internal']
Default configuration.
--- Original
+++ New
<?php
/**
* @internal
*/
-class Sample
+final class Sample
{
}
With configuration: ['include' => ['@Custom'], 'exclude' => ['@not-fix']]
.
--- Original
+++ New
<?php
/**
* @CUSTOM
*/
-class A{}
+final class A{}
/**
* @CUSTOM
* @not-fix
*/
class B{}
The rule is part of the following rule set:
- Fixer class: PhpCsFixer\Fixer\ClassNotation\FinalInternalClassFixer
- Test class: PhpCsFixer\Tests\Fixer\ClassNotation\FinalInternalClassFixerTest
The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.