File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -304,11 +304,13 @@ correctly. To validate the types of the options, call
304
304
$resolver->setAllowedTypes('host', 'string');
305
305
306
306
// specify multiple allowed types
307
- $resolver->setAllowedTypes('port', ['null', 'int']);
307
+ $resolver->setAllowedTypes('port', ['int', 'null']);
308
+ $resolver->setAllowedTypes('port', 'int|null');
308
309
309
310
// check all items in an array recursively for a type
310
- $resolver->setAllowedTypes('dates', 'DateTime[]');
311
311
$resolver->setAllowedTypes('ports', 'int[]');
312
+ $resolver->setAllowedTypes('dates', 'DateTime[]');
313
+ $resolver->setAllowedTypes('dates', '(DateTime|DateTimeImmutable)[]');
312
314
}
313
315
}
314
316
@@ -331,6 +333,10 @@ is thrown::
331
333
In sub-classes, you can use :method: `Symfony\\ Component\\ OptionsResolver\\ OptionsResolver::addAllowedTypes `
332
334
to add additional allowed types without erasing the ones already set.
333
335
336
+ .. versionadded :: 7.3
337
+
338
+ The support of union types was introduced in Symfony 7.3.
339
+
334
340
.. _optionsresolver-validate-value :
335
341
336
342
Value Validation
You can’t perform that action at this time.
0 commit comments