Skip to content

Convert switch cases to match expression #47654

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 23, 2022
Merged

Conversation

tigitz
Copy link
Contributor

@tigitz tigitz commented Sep 21, 2022

Q A
Branch? 6.2
Bug fix? no
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR

Continuation of #45433 using rector rule

@fancyweb friendly ping as you've worked on it previously.

Copy link
Member

@wouterj wouterj left a comment

Choose a reason for hiding this comment

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

Imho, only the change in src/Symfony/Component/Serializer/Normalizer/UidNormalizer.php should be kept.

Changes in existing code increases maintenance (we have to review & merge it, make sure it doesn't break a single thing in a release, fix merge conflicts when upmerging older branches, etc.). As such they must provide value.

For a match, this value is the fact that is an expression - unlike switch. So imho, we should only change switch statements that are used as expression (which is only the one in the Serializer component). This also seems to have been the case with the previous PR introducing most match expressions to the code base.

@tigitz
Copy link
Contributor Author

tigitz commented Sep 21, 2022

@wouterj I understand your POV, however to me it brings value in code readability but also reliability since match is a strict comparison. But you obviously know better than me if it's worth it as I don't realize the impact of the increased maintenance.

If that's ok with you I'll let other core members confirm your stance and make the appropriate modifications. Thanks.

@nicolas-grekas
Copy link
Member

Personally I find the code more readable when using match. The change is fine to me.

@wouterj wouterj dismissed their stale review September 21, 2022 20:18

Ok then, I'll dismiss my -1. Thanks for sharing your opinions :)

@fabpot
Copy link
Member

fabpot commented Sep 23, 2022

Thank you @tigitz.

@fabpot fabpot merged commit 6e4ce77 into symfony:6.2 Sep 23, 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.

8 participants