Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: add sniff to check spacing around spread operators #2100

Merged
merged 1 commit into from
Oct 29, 2022

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Oct 28, 2022

  1. There should be one space, or a new line + appropriate indentation, before the spread operator.
  2. There should be no space between the spread operator and the variable/function call it applies to.
  3. When combining the spread operator with the reference operator, there should be no space between them.

Includes excluding a particular error code from the Squiz.Functions.FunctionDeclarationArgumentSpacing sniff to prevent duplicate messages about the same thing.

Refs:

Fixes #1762

Also note: there are currently two PRs open in PHPCS upstream for the Generic.WhiteSpace.SpreadOperatorSpacingAfter sniff:

> 1. There should be one space, or a new line + appropriate indentation, before the spread operator.
> 2. There should be no space between the spread operator and the variable/function call it applies to.
> 3. When combining the spread operator with the reference operator, there should be no space between them.

Includes excluding a particular error code from the `Squiz.Functions.FunctionDeclarationArgumentSpacing` sniff to prevent duplicate messages about the same thing.

Refs:
* https://make.wordpress.org/core/2020/03/20/updating-the-coding-standards-for-modern-php/ - Operators section
* https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#spread-operator
* WordPress/wpcs-docs 105
* WordPress/WordPress-Coding-Standards 1762
* squizlabs/PHP_CodeSniffer 2548

Fixes 1762

Also note: there are currently two PRs open in PHPCS upstream for the `Generic.WhiteSpace.SpreadOperatorSpacingAfter` sniff:
* The first -  squizlabs/PHP_CodeSniffer 3647 - is inconsequential as it only involves a message tweak.
* The second - squizlabs/PHP_CodeSniffer 3694 - is related to PHP 8.1 first class callables and will prevent the sniff from triggering on those.
Copy link
Member

@GaryJones GaryJones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GaryJones GaryJones merged commit 9810968 into develop Oct 29, 2022
@GaryJones GaryJones deleted the feature/core-add-spreadoperator-rules branch October 29, 2022 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proposal: Add rules about formatting of the spread operator
3 participants