Problem/Motivation
The Drupal 8 coding standard guide states
The @file doc block MUST be present for all PHP files, with one exception: files that contain a namespaced class/interface/trait, whose file name is the class name with a .php extension, and whose file path is closely related to the namespace (under PSR-4 or a similar standard), SHOULD NOT have a @file documentation block.
We see this violated throughout Examples.
Proposed resolution
See the parent issue for instructions on how to install phpcs.
- Add the
Drupal.Commenting.FileComment.NamespaceNoFileDocsniff as a rule tophpcs.xml.dist. - Run
phpcfbto make automated changes. - Review the changes made by
phpcbf. - Run
phpcsin order to verify that the error no longer exists. - Submit a patch with all changed files, remembering to include the changes to
phpcs.xml.distin the patch.
To Review
To review this issue you should:
- Install phpcs. Instructions in the meta: #2176147: [meta] Coding standards review for D8 Examples
- Apply the patch.
- Run
phpcson Examples to determine whether the error is fixed. - Read the patch for a more subjective review.
How to run phpcs?
If you've installed phpcs as per the instructions in the meta, you can then change directories into the examples module and use .. to execute the phpcs executable you just installed. Like this:
$ pwd
/PATH/TO/drupal/modules/examples
$ ../../vendor/bin/phpcs -p -s
[ ...phpcs results print out... ]
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | interdiff.txt | 1.03 KB | mile23 |
| #11 | interdiff.txt | 630 bytes | imalabya |
| #11 | 2735851-11.patch | 41.94 KB | imalabya |
| #8 | 2735851-8.patch | 41.27 KB | imalabya |
| #6 | 2735851-6.patch | 41.62 KB | imalabya |
Comments
Comment #2
imalabyaComment #3
mile23Thanks for the issue and the patch. I'm re-scoping this a little to include the parent issue and instructions on how to make all the changes semiautomatically.
Comment #4
mile23Comment #5
mile23Comment #6
imalabyaHi Miles23, here is an updated patch for the sniffs. The method really helped to make it quick. Please review if everything looks good. Not adding any interdiff as it's a new patch with the old changes as well.
Comment #7
imalabyaComment #8
imalabyaUploading the patch, removed composer.json changes which were added by mistake.
Comment #9
mile23Updating issue summary with review instructions.
Comment #10
mile23Nice. Except for one thing:
Move this comment to an appropriate place in config_entity_example.module's @defgroup block.
Comment #11
imalabyaHere is the updated patch and interdiff.
Comment #12
imalabyaComment #13
mile23Thanks!
Oh, didn't notice this before, sorry.
I think this is a good change, since the class itself is tagged @ingroup. But that leaves the @} at the end of the file, which needs to be removed.
After that, we only have these two:
Comment #15
mile23Fixed the remainder on commit. Thanks!