Skip to content

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 <[email protected]>
@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

Development

Successfully merging this pull request may close these issues.

2 participants