PEAR/FunctionComment: bug fix - handling of blank lines in pre-amble #830
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.
Description
The
PEAR.Commenting.FunctionComment
sniff intends to flag blank lines between a function docblock and the function declaration.However, as things are, there are - IMO - two bugs in the logic for this:
Given a code block which looks like this:
There will be only one error and it will read:
This is confusing as the blank line may not be after the function comment, but after an attribute instead.
Additionally, the sniff also flags blank lines within attributes, while that is outside of the purview of the sniff. (Should be handled by an attribute specific sniff)
What I would expect would be for the sniff to:
a) Throw a separate error for each (set of) blank lines found.
b) For the error message to more accurately reflect what is being flagged.
This commit changes the
SpacingAfter
error to comply with the above expectationsIncludes test, though there are also some pre-existing tests which show this issue and for which the behaviour is changed.
Note: while it will still be messy, it may be easier to review this PR while ignoring whitespace changes.
Suggested changelog entry
PEAR.Commenting.FunctionComment: improved message for "blank lines between docblock and declaration" check.
PEAR.Commenting.FunctionComment will no longer remove blank lines within attributes.
Related issues/external references
Loosely related to #152
Types of changes