-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[OptionsResolver] Support union of types #59354
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
Conversation
Hey! Thanks for your PR. You are targeting branch "7.3" but it seems your PR description refers to branch "7.3 for features". Cheers! Carsonbot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good addition 👍 thanks!
src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php
Outdated
Show resolved
Hide resolved
Also, we could find a regex that matches all possible variants instead of checking them one by one. |
Didn't find an easy one, but I'm opened to suggestion. I preferred to add the logic in the existing recursive implementation |
c5fd1c9
to
f34466a
Compare
I found edge case where my previous implementation remove badly parenthesis, so I now introduce a private method |
src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php
Outdated
Show resolved
Hide resolved
Could you confirm that class Union is also supported with this new syntax? i.e. |
5aed5da
to
aca37dc
Compare
I added a test for |
c43650c
to
b108355
Compare
Thank you @VincentLanglet. |
…hangelog (alamirault) This PR was merged into the 7.3 branch. Discussion ---------- [OptionsResolver] Add missing support of union type in changelog | Q | A | ------------- | --- | Branch? | 7.3 | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Issues | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead --> | License | MIT I found changelog is missing while documenting symfony/symfony-docs#20531 Code PR: #59354 Commits ------- 946278f [OptionsResolver] Add missing support of union type
Add support for
|
syntax when describing allowedType in OptionResolver.It's not really useful for
int|string
since we can pass an array['string', 'int']
.But it's useful for array values since
(int|string)[]
was not possible so far and['string[]', 'int[]']
was not the same thing.