Skip to content

Replace switch statement with match expression #17287

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

Merged
merged 1 commit into from
Sep 27, 2022

Conversation

ker0x
Copy link
Contributor

@ker0x ker0x commented Sep 22, 2022

No description provided.

Copy link
Member

@javiereguiluz javiereguiluz left a comment

Choose a reason for hiding this comment

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

I like this ... and there are so few switch occurrences that I think it's worth the effort of updating this in our code examples.

@ker0x
Copy link
Contributor Author

ker0x commented Sep 23, 2022

@javiereguiluz Actually, the only other code example that I found with a switch is here!

Should I also replace it with:

 match ($name) {
    // set use_acme_goodbye to false in the config of
    // acme_something and acme_other
    //
    // note that if the user manually configured
    // use_acme_goodbye to true in config/services.yaml
    // then the setting would in the end be true and not false
    'acme_something', 'acme_other' => $container->prependExtensionConfig($name, $config),
    default => null
}

?

@OskarStark
Copy link
Contributor

Should I also replace it with:

Yes please 💪

@ker0x
Copy link
Contributor Author

ker0x commented Sep 25, 2022

@OskarStark Done 😉 !

@javiereguiluz
Copy link
Member

Romain, thanks for another very nice contribution! The new match expressions look neat and concise 😍

@javiereguiluz javiereguiluz merged commit f3b5b7b into symfony:6.0 Sep 27, 2022
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.

6 participants