Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions components/options_resolver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,20 @@ correctly. To validate the types of the options, call

// specify multiple allowed types
$resolver->setAllowedTypes('port', ['null', 'int']);
// which is similar to
$resolver->setAllowedTypes('port', 'int|null');

// check all items in an array recursively for a type
$resolver->setAllowedTypes('dates', 'DateTime[]');
$resolver->setAllowedTypes('ports', 'int[]');
$resolver->setAllowedTypes('endpoints', '(int|string)[]');
}
}

.. versionadded:: 7.3

Union of type, using the ``|`` syntax, was introduced in Symfony 7.3.

You can pass any type for which an ``is_<type>()`` function is defined in PHP.
You may also pass fully qualified class or interface names (which is checked
using ``instanceof``). Additionally, you can validate all items in an array
Expand Down
Loading