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

Squiz/PSR12/OperatorSpacing: bug fix - unary plus/minus in arrow function return #3129

Conversation

jrfnl
Copy link
Contributor

@jrfnl jrfnl commented Sep 29, 2020

A plus/minus directly after the arrow of an arrow function, will always be a unary plus/minus and should therefore be ignored by these sniffs.

Includes unit tests.

Includes two additional simplifications:

  • T_DOUBLE_ARROW is already part of the Tokens::$assignmentTokens array, so doesn't need to be added separately.
  • The cast tokens array was incomplete (missing T_BINARY_CAST) and can be replaced by the more complete Tokens::$castTokens array anyhow.

Fixes #3043

…tion return

A plus/minus directly after the arrow of an arrow function, will always be a unary plus/minus and should therefore be ignored by these sniffs.

Includes unit tests.

Includes two additional simplifications:
* `T_DOUBLE_ARROW` is already part of the `Tokens::$assignmentTokens` array, so doesn't need to be added separately.
* The cast tokens array was incomplete (missing `T_BINARY_CAST`) and can be replaced by the more complete `Tokens::$castTokens` array anyhow.

Fixes 3043
@jrfnl
Copy link
Contributor Author

jrfnl commented Sep 29, 2020

@gsherwood As there are already three other fixes for the operator spacing sniffs in 3.5.7, including two others related to arrow functions, I imagine this one can go into 3.5.7 as well.

@gsherwood gsherwood added this to Idea Bank in PHPCS v3 Development via automation Sep 29, 2020
@gsherwood gsherwood added this to the 3.5.7 milestone Sep 29, 2020
gsherwood added a commit that referenced this pull request Oct 13, 2020
@gsherwood gsherwood merged commit efcd173 into squizlabs:master Oct 13, 2020
PHPCS v3 Development automation moved this from Idea Bank to Ready for Release Oct 13, 2020
@gsherwood
Copy link
Member

Thanks for the fix and general sniff cleanup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
PHPCS v3 Development
Ready for Release
Development

Successfully merging this pull request may close these issues.

Squiz.WhiteSpace.OperatorSpacing false positive for negation in arrow function
2 participants