Skip to content

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

Merged
jrfnl merged 1 commit into
developfrom
operators/isunaryplusminus-allow-for-match-arrows
Aug 27, 2022
Merged

jrfnl merged 1 commit into
developfrom
operators/isunaryplusminus-allow-for-match-arrows

Conversation

@jrfnl

@jrfnl jrfnl commented Aug 27, 2022 •

Copy link
Copy Markdown
Member

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

jrfnl commented Aug 27, 2022

Copy link
Copy Markdown
Member Author

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.

1 participant