Skip to content

[Routing] Remove variadic constructor signature #46157

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
Apr 27, 2022

Conversation

wouterj
Copy link
Member

@wouterj wouterj commented Apr 25, 2022

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

Just a little suggestion, based on today's "New in Symfony" blogpost.

Subjective argument: the variadic signature felt a bit weird, as argument 1 has a different meaning than 2+ (but they look very similar due to PHP's ::class "magic constant")
Objective argument: variadic signature is harder with BC layers when we want to add another argument. Personally, I feel like we have to be careful about using variadic signatures in Symfony.

@chalasr
Copy link
Member

chalasr commented Apr 25, 2022

Can you check if the build failure is related?

@wouterj wouterj force-pushed the pr-45803/backendenum branch from 6c47d2f to 6d908cd Compare April 25, 2022 11:03
@wouterj
Copy link
Member Author

wouterj commented Apr 25, 2022

Fixed fabbot, the CI test failures are caused by changes in PHP 8.2 upstream. You can see the same errors in e.g. https://github.com/symfony/symfony/runs/6146660539

Btw, let's mark PHP 8.2 tests as experimental again: #46160

@nicolas-grekas
Copy link
Member

The benefit of using variadic was the type check enforced by PHP.
I'm really fine doing that but I'd suggest going one step further and allow only one argument: array|string $cases
When array, we should enforce that all cases have the same class.

@fancyweb
Copy link
Contributor

I'm really fine doing that but I'd suggest going one step further and allow only one argument: array|string $cases

👍 or 👎?

@wouterj wouterj force-pushed the pr-45803/backendenum branch from 05ade4d to a04756f Compare April 27, 2022 10:07
@wouterj
Copy link
Member Author

wouterj commented Apr 27, 2022

👍 for string|array - just updated the PR

@fancyweb
Copy link
Contributor

It's actually \BackedEnum|array, I updated it.

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

(I updated the PR to my proposal)

@fabpot
Copy link
Member

fabpot commented Apr 27, 2022

Thank you @wouterj.

* @var string[]
*/
private readonly array $values;
private string $requirement;
Copy link
Contributor

Choose a reason for hiding this comment

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

@nicolas-grekas Why did you remove the readonly?

Copy link
Member

Choose a reason for hiding this comment

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

Not intentional! (But read-only on private is not useful either so 🤷‍♂️ 😆)

@wouterj wouterj deleted the pr-45803/backendenum branch April 28, 2022 13:04
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