✨ New Universal.WhiteSpace.CommaSpacing
sniff
#254
Merged
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.
New sniff to enforce no space before a comma and exactly one space, or a new line, after a comma.
Additionally, the sniff also enforces that the comma should follow the code and not be placed after a trailing comment.
For the spacing part, the sniff makes the following exceptions:
These will not be flagged to prevent conflicts with sniffs handling spacing around braces.
These will not be flagged.
In that case, unless the
php_version
config directive is set to a version higher than PHP 7.3.0, a new line before will be enforced to prevent parse errors on PHP < 7.3.The sniff has a separate error code for when a comma is found with more than one space after it, followed by a trailing comment.
That way trailing comment alignment can be allowed by excluding that error code.
Additionally, the sniff uses modular error code suffixes for select situations, like
*InFunctionDeclaration
,*InFunctionCall
, to allow for preventing duplicate messages if another sniff is already handling the comma spacing.Includes raising the minimum PHPCSUtils version to
1.0.8
to prevent running into a particular bug in theSpacesFixer
.Note: a few of the test files will only run when the tests are run on PHP 7.3+ as the tests involve PHP 7.3+ flexible heredoc/nowdoc tokens, which is the one syntax which PHPCS cannot polyfill in the Tokenizer.
Includes fixers.
Includes unit tests.
Includes documentation.
Includes metrics.