You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature #59354 [OptionsResolver] Support union of types (VincentLanglet)
This PR was squashed before being merged into the 7.3 branch.
Discussion
----------
[OptionsResolver] Support union of types
| Q | A
| ------------- | ---
| Branch? | 7.3
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Issues | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead -->
| License | MIT
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.
Commits
-------
69ec31d [OptionsResolver] Support union of types
@@ -878,6 +925,7 @@ public static function provideInvalidTypes()
878
925
[[null], ['string[]', 'string'], 'The option "option" with value array is expected to be of type "string[]" or "string", but one of the elements is of type "null".'],
879
926
[['string', null], ['string[]', 'string'], 'The option "option" with value array is expected to be of type "string[]" or "string", but one of the elements is of type "null".'],
880
927
[[\stdClass::class], ['string'], 'The option "option" with value array is expected to be of type "string", but is of type "array".'],
928
+
[['foo', 12], '(string|bool)[]', 'The option "option" with value array is expected to be of type "(string|bool)[]", but one of the elements is of type "int".'],
881
929
];
882
930
}
883
931
@@ -1903,6 +1951,26 @@ public function testNestedArrays()
0 commit comments