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

Operators::isUnaryPlusMinus(): allow for match control structures #335

Merged
merged 1 commit into from
Aug 27, 2022

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Aug 27, 2022

Operators::isUnaryPlusMinus(): allow for match control structures

The double arrow in PHP 8.0 match control structures has its own T_MATCH_ARROW token.
This token needs to be taken into account when determining if a plus/minus token is unary or arithmetic.

This token was introduced in PHPCS 3.6.0 and will be tokenized as T_DOUBLE_ARROW for older PHPCS versions.
The method already looks for T_DOUBLE_ARROW before the operator, so checking for T_MATCH_ARROW solely based on token type will handle match arrow tokens in a PHPCS-cross-version compatible manner.

Ref: squizlabs/PHP_CodeSniffer#3653

The double arrow in PHP 8.0 match control structures has its own `T_MATCH_ARROW` token.
This token needs to be taken into account when determining if a plus/minus token is unary or arithmetic.

This token was introduced in PHPCS 3.6.0 and will be tokenized as `T_DOUBLE_ARROW` for older PHPCS versions.
The method already looks for `T_DOUBLE_ARROW` before the operator, so checking for `T_MATCH_ARROW` solely based on token type will handle match arrow tokens in a PHPCS-cross-version compatible manner.

Ref: squizlabs/PHP_CodeSniffer 3653

Co-authored-by: Jaroslav Hanslík <kukulich@kukulich.cz>
@jrfnl
Copy link
Member Author

jrfnl commented Aug 27, 2022

Coveralls is still drunk. Merging.

@jrfnl jrfnl merged commit 262736b into develop Aug 27, 2022
@jrfnl jrfnl deleted the operators/isunaryplusminus-allow-for-match-arrows branch August 27, 2022 20:13
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.

None yet

1 participant