PHP 8.1: New PHPCompatibility.Classes.NewFinalClassConstants sniff#1317
PHP 8.1: New PHPCompatibility.Classes.NewFinalClassConstants sniff#1317
PHPCompatibility.Classes.NewFinalClassConstants sniff#1317Conversation
> Added support for the final modifier for class constants. Also, interface constants become overridable by default. New sniff to detect this new feature. Note: the sniff does not do anything special for non-final interface constants which previously were not overridable. Includes unit tests. Includes docs. Refs: * https://wiki.php.net/rfc/final_class_const * https://www.php.net/manual/en/migration81.new-features.php#migration81.new-features.core.final-constants * https://www.php.net/manual/en/language.oop5.final.php#language.oop5.final.example.php81 * php/php-src#6878 * php/php-src@a5360e8
|
@afilina And another one. |
| <code title="PHP >= 8.1: using the final modifier."> | ||
| <![CDATA[ | ||
| class Foo { | ||
| <em>final</em> const BAR = 10; |
There was a problem hiding this comment.
The HTML tag appears literally in markdown docs. I recommend avoiding markdown in code samples. Other than that, everything looks good on the docs side.
| <em>final</em> const BAR = 10; | |
| final const BAR = 10; |
There was a problem hiding this comment.
The <em> markers are intended to highlight the "issue" in the HTML view.
In the Text and the MarkDown view, they are automatically removed when the report is generated.
How did you generate the report to get them to show ?
There was a problem hiding this comment.
Just checked the source code of the generators which are included with PHPCS and the above is correct. Also tested with the docs for another sniff I was just working on.
There was a problem hiding this comment.
This is the generator code I mean: https://github.com/squizlabs/PHP_CodeSniffer/blob/51335eb46b2b940b6c429643fe96f514d4a4e4a1/src/Generators/Markdown.php#L131-L141
If the code in the phpcs docs repo does not line up with that, it will need to be adjusted.
New sniff to detect this new feature.
Note: the sniff does not do anything special for non-final interface constants which previously were not overridable.
Includes unit tests.
Includes docs.
Refs:
Related to #1299