Problem/Motivation
#2776975: March 3, 2017: Convert core to array syntax coding standards for Drupal 8.3.x RC phase landed for Drupal 8. We noticed that many of the API docs using long array syntax and we'd like to build a rule that would check the comments of the PHP files if possible.
Proposed resolution
Possibly parse comments ala annotations and token parse array() (not sure if this is possible but a suggestion)
Remaining tasks
Adding a rule has postponed this implementation of the rule #2874067: Fix Drupal.Commenting.DocCommentLongArraySyntax coding standard
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | enforce_short_array-2857906-4.patch | 2.82 KB | hampercm |
Comments
Comment #2
joelpittetComment #3
hampercm commentedSprinting on this for MidCamp2017
Comment #4
hampercm commentedThis patch adds a sniff for long array syntax use inside @code annotations.
Comment #5
hampercm commentedComment #6
blakehall commentedThis is looking good to me! (after wrestling with coder/phpcs for too long)
Thanks @hampercm!
Comment #7
klausiHm, the regex comparison is a bit raw for PHP code, but maybe good enough for short @code blocks?
We also need a test case for this. And can you file this as pull request against https://github.com/pfrenssen/coder where the automated tests run? Thanks!
Comment #8
spokjehttps://github.com/pfrenssen/coder/pull/160
Comment #9
spokjeComment #10
klausiThanks, left some minor comments on the pull request.
Comment #11
spokjeThanks @klausi.
I've changed the PR.
(Note: I'm not the original patch creator, just the guy that whacked it into a PR).
Comment #13
klausiMerged, thanks!
Comment #15
claudiu.cristeaThis new rule did introduce a bug #3306999: PHPCS hangs indefinetly with standard Drupal on file FieldPluginBase.php