Problem/Motivation
Currently enums introduced in PHP 8.1 are not supported.
This leads to Sniffs like Drupal.Commenting.FileComment requiring a file comment for PHP files containing an enum.
Steps to reproduce
Run said sniff on a PHP file containing an enum.
Proposed resolution
Define T_ENUM constant if it does not exist to avoid errors and add backwards compatibility.
Update Sniffs to also check for T_ENUM constant:
Drupal.Classes.ClassDeclaration
Drupal.Classes.ClassFileName
Drupal.Classes.UseGlobalClass
Drupal.Commenting.ClassComment
Drupal.Commenting.FileComment
Drupal.Commenting.InlineComment
Drupal.Commenting.InlineVariableComment
Drupal.Methods.MethodDeclaration
Drupal.Scope.MethodScope
Drupal.InfoFiles.ClassFiles
Note:
Please note that those changes only work when squizlabs/PHP_CodeSniffer releases the next version to include support for T_ENUM.
Issue fork coder-3283741
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3283741-enums
changes, plain diff MR !14
Comments
Comment #2
chfoidl commentedComment #3
chfoidl commentedComment #5
chfoidl commentedComment #7
klausiMarking as "needs work"
Comment #8
kevinquillen commentedRunning into this same issue. It does not work with the latest version, throwing the same error mentioned in the original post.
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
1 | ERROR | [x] Missing file doc comment
Comment #9
solideogloria commentedComment #10
claudiu.cristeaAdded as PR: https://github.com/pfrenssen/coder/pull/209
Comment #11
claudiu.cristea@klausi, current tests are green but no new tests
Comment #12
claudiu.cristeaOK, I give up. No idea on how to test this
Comment #13
pfrenssenThanks a lot for making the MR! I will add some test coverage.
Comment #14
pfrenssenThanks!
Comment #17
alexander allen commentedUnrelated to the file comment, but still related to enums, the coding standard does not let you add comments, specifically doc-block comments to enum cases.
Example: