-
-
Notifications
You must be signed in to change notification settings - Fork 737
[PHP 8.0] Add ChangeSwitchToMatchRector #3569
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
Conversation
bb8ef27 to
7c4e72a
Compare
eec13d9 to
8738a99
Compare
8738a99 to
9de05c9
Compare
|
@ondrejmirtes Hi Ondra, here is the failing CI job I made just for this issue: Only running |
|
I've just added separated jobs for:
Everything else in the code is the same |
54a8582 to
9a0598c
Compare
|
I probably know what this is about:
I really don't know the way out of this, it's a hard problem. |
|
Great! I came to exact same conclussion. |
|
The only solution that worked for me in the past is to use the same php-parser as PHPStan does. |
|
I'll be releasing PHPStan 0.12.34 with PHP-Parser 4.7 later today 🚀 |
|
That's way over my expectations. Epic, thank you 👏 ❤️ |
7b4cbaa to
7796219
Compare
909a974 to
dc14ddd
Compare
|
@ondrejmirtes I've just updated Rector and can confirm 0.12.34 works purfectly! Thanks 👏 👏 |
|
Cool :) |
Covers nikic/PHP-Parser#672, https://wiki.php.net/rfc/match_expression_v2
class SomeClass { public function run() { - $statement = switch ($this->lexer->lookahead['type']) { - case Lexer::T_SELECT: - $statement = $this->SelectStatement(); - break; - default: - $this->syntaxError('SELECT, UPDATE or DELETE'); - break; - } + $statement = match ($this->lexer->lookahead['type']) { + Lexer::T_SELECT => $this->SelectStatement(), + default => $this->syntaxError('SELECT, UPDATE or DELETE'), + }; } }Ref #3127