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

Migrate Parser to PHP 8 #10506

Merged
merged 1 commit into from
Feb 7, 2023
Merged

Migrate Parser to PHP 8 #10506

merged 1 commit into from
Feb 7, 2023

Conversation

greg0ire
Copy link
Member

@greg0ire greg0ire commented Feb 7, 2023

In some cases, I had to widen the documented type, running the test suite showed me it was wrong.

*/
public function SimpleConditionalExpression()
*/
public function SimpleConditionalExpression(): AST\ExistsExpression|AST\BetweenExpression|AST\LikeExpression|AST\InListExpression|AST\InSubselectExpression|AST\InstanceOfExpression|AST\CollectionMemberExpression|AST\NullComparisonExpression|AST\EmptyCollectionComparisonExpression|AST\ComparisonExpression
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I simplify this one to AST\Node?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depends on how we answer my question regarding final. 🙂

Copy link
Member

@derrabus derrabus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we finalize the Parser class? With all those native union types, it'll otherwise hard to change that method in the future.

match (true) {
$AST instanceof AST\UpdateStatement => $treeWalkerChain->walkUpdateStatement($AST),
$AST instanceof AST\DeleteStatement => $treeWalkerChain->walkDeleteStatement($AST),
default => $treeWalkerChain->walkSelectStatement($AST),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's be explicit about the remaining case that we expect here. Static analysis should recognize that the match statement covers all cases without a default and will notify us if that will ever change in the future. 💪🏻

Suggested change
default => $treeWalkerChain->walkSelectStatement($AST),
$AST instanceof AST\SelectStatement => $treeWalkerChain->walkSelectStatement($AST),

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks nicer indeed 👍

@greg0ire
Copy link
Member Author

greg0ire commented Feb 7, 2023

Let's try final. If it turns out this was a wrong move, we can always remove it afterwards, after adjusting the return types.

@greg0ire greg0ire merged commit dfcb20e into 3.0.x Feb 7, 2023
@greg0ire greg0ire deleted the php8-migration branch February 7, 2023 23:01
@greg0ire greg0ire added this to the 3.0.0 milestone Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants