PHPCS ruleset: add sniff to check spacing between property declarations #135
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.
The
Yoast.WhiteSpace.FunctionSpacing
sniff which was added in PR #86 checks that each function within an OO structure has one blank line before the function declaration and no blank line(s) after the last function in a class.This sniff was added as there was quite some inconsistency regarding this across classes and repos and this way we could enforce consistency.
Similar to this, we should also enforce consistency regarding the spacing out of property declarations in OO structures, which I've noticed becoming inconsistent in some repos as well.
The sniff I'm proposing to add, is a PHPCS native sniff which checks that there is one blank line before the first property declaration in an OO structure, as well as one blank line between property declarations in OO structures.
The sniff includes an auto-fixer.
Ref: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Customisable-Sniff-Properties#squizwhitespacemembervarspacing
Code sample:
Incorrect:
Correct: