Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commenting/FileComment: allow for namespaced procedural files and other improvements #333

Merged
merged 3 commits into from
Nov 4, 2023

Conversation

jrfnl
Copy link
Collaborator

@jrfnl jrfnl commented Nov 4, 2023

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.

jrfnl added 3 commits November 4, 2023 02:36
... for a few edge cases previously not covered by tests.
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.
@coveralls
Copy link

Coverage Status

coverage: 98.18% (+0.1%) from 98.067%
when pulling 7eb259e on JRF/yoastcs-filecomment-various-improvements
into 5c36089 on develop.

@jrfnl jrfnl merged commit 80457d5 into develop Nov 4, 2023
25 checks passed
@jrfnl jrfnl deleted the JRF/yoastcs-filecomment-various-improvements branch November 4, 2023 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants