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

PHP 8.0: add support for match expressions #356

Merged
merged 2 commits into from
Oct 15, 2022

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Oct 15, 2022

PHP 8.0 | Arrays::getDoubleArrowPtr(): allow for match expressions in array values

PHP 8.0 introduced match expressions, which can contain arrays in both the match "case" as well as the match value.
Skipping over match expressions will prevent incorrect results for the Arrays::getDoubleArrowPtr() method (in particular when a match expression is used as an array key).

Includes unit tests.

Refs:

PHP 8.0 | ControlStructures::hasBody(): add support for match expressions

PHP 8.0 introduced match expressions as an new control structure.

While a match expression without body or with an empty body is not allowed and would result in a fatal error (or be interpreted as a non-global function call), the ControlStructures::hasBody() method should still handle it correctly.

Includes adding the T_MATCH token to the Collections::controlStructureTokens() token array.

Includes unit tests.

Refs:

… array values

PHP 8.0 introduced match expressions, which can contain arrays in both the match "case" as well as the match value.
Skipping over match expressions will prevent incorrect results for the `Arrays::getDoubleArrowPtr()` method (in particular when a match expression is used as an array key).

Includes unit tests.

Refs:
* https://wiki.php.net/rfc/match_expression_v2
@jrfnl jrfnl added this to the 1.0.0-alpha4 milestone Oct 15, 2022
@jrfnl jrfnl force-pushed the php8.0/add-support-for-match-expressions branch from dc61f13 to c5a9956 Compare October 15, 2022 03:50
@jrfnl jrfnl changed the title Php8.0/add support for match expressions PHP 8.0: add support for match expressions Oct 15, 2022
…ions

PHP 8.0 introduced match expressions as an new control structure.

While a `match` expression without body or with an empty body is not allowed and would result in a fatal error (or be interpreted as a non-global function call), the `ControlStructures::hasBody()` method should still handle it correctly.

Includes adding the `T_MATCH` token to the `Collections::controlStructureTokens()` token array.

Includes unit tests.

Refs:
* https://wiki.php.net/rfc/match_expression_v2
@jrfnl jrfnl force-pushed the php8.0/add-support-for-match-expressions branch from c5a9956 to 390e964 Compare October 15, 2022 03:51
@jrfnl jrfnl merged commit 25ac2cd into develop Oct 15, 2022
@jrfnl jrfnl deleted the php8.0/add-support-for-match-expressions branch October 15, 2022 03:59
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