Commenting/FileComment: allow for namespaced procedural files and other improvements #333
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Commenting/FileComment: add notes about parse errors to a few test files
Commenting/FileComment: add extra tests
... for a few edge cases previously not covered by tests.
Commenting/FileComment: allow for namespaced procedural files
The
Yoast.Commenting.FileComment
sniff would previously demand a file docblock for non-namespaced files and recommend a file docblock be removed for namespaced files.This is all well and good for namespaced files containing an OO declaration, where the OO structure will generally have a docblock, but for namespaced procedural files, this might mean the file will end up having no documentation whatsoever, which could be counter-productive.
While namespaced procedural files are not that common in the Yoast codebases, typically a PHPUnit bootstrap file may be a namespaced procedural file.
This commit updates the sniff to only recommend removing the file docblock if the file also contains a named OO declaration.
For namespaced files which don't contain an OO declaration, the file docblock will still be allowed (but not required) and will no longer be flagged as unnecessary.
If a docblock is found in such a file, it will be checked for compliance with file docblock rules like any other file docblock.
Includes ample tests.
Includes updated XML documentation.