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

[9.x] Use match expression where possible #39583

Merged
merged 3 commits into from
Nov 15, 2021

Conversation

seriquynh
Copy link
Contributor

Laravel 9 will require PHP 8.0 as the minimum version, so we are free to use match expression. In this PR, I try to convert a few switch statements into match expressions that makes code easier to read.

Please review the code changes and see how nice the match expression is.

return match ($driver) {
'database' => $this->createDatabaseProvider($config),
'eloquent' => $this->createEloquentProvider($config),
default => (throw new InvalidArgumentException(
Copy link
Member

Choose a reason for hiding this comment

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

Why is the throw wrapped in parentheses?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are not necessary. I removed them.

@taylorotwell taylorotwell merged commit 23cdfcf into laravel:master Nov 15, 2021
@driesvints
Copy link
Member

@seriquynh this seem to have broken the default null return in a couple of places: #40880

@seriquynh
Copy link
Contributor Author

@driesvints I'm sorry for missing your mention because I haven't check github for a while. I see a fixed PR has been merged. Thanks for you guys!

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.

3 participants