Add new Yoast.WhiteSpace.FunctionSpacing
sniff
#86
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.
Turns out the upstream
Squiz.WhiteSpace.FunctionSpacing
sniff which was added in PR #83, examines all functions and not just the functions in classes and other OO structures.This is problematic for code which follows a pattern like this:
.. in that the sniff demands a blank line between the
if
and the docblock, as well as between the function close brace line and theif
close brace line.Especially that last one is problematic as it causes a fixer conflict with the
ControlStructureSpacing
sniff which demands no blank lines at the end of control structures.This has now been solved by adding a new Yoast sniff which extends the original upstream sniff, but makes sure that the sniff is only applied to methods within OO-structures.
Functions in the global namespace will no longer be examined by the sniff.
The Yoast version of the sniff overloads the public properties from the parent sniff with the Yoast specific config.
If so desired for individual projects, these public properties can still be overruled by setting them in a custom ruleset.
Includes unit tests for the sniff as well as the fixer.