Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ New
Universal.WhiteSpace.CommaSpacing
sniff
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: 1. A comma preceded or followed by a parenthesis, curly or square bracket. These will not be flagged to prevent conflicts with sniffs handling spacing around braces. 2. A comma preceded or followed by another comma, like for skipping items in a list assignment. These will not be flagged. 3. A comma preceded by a non-indented heredoc/nowdoc closer. 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 the `SpacesFixer`. 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.
- Loading branch information