Skip to content

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

Merged
gsherwood merged 1 commit intosquizlabs:masterfrom
jrfnl:feature/3043/psr12-operatorspacing-bug-with-arrow-functions
Oct 13, 2020
Merged

Squiz/PSR12/OperatorSpacing: bug fix - unary plus/minus in arrow function return#3129
gsherwood merged 1 commit intosquizlabs:masterfrom
jrfnl:feature/3043/psr12-operatorspacing-bug-with-arrow-functions

Conversation

@jrfnl
Copy link
Copy Markdown
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
Copy Markdown
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 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
@gsherwood
Copy link
Copy Markdown
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

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants