Skip to content

[OptionsResolver] add ignoreUndefined() #18302

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
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
23 changes: 23 additions & 0 deletions components/options_resolver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,29 @@ the option::
This closure receives as argument the value of the option after validating it
and before normalizing it when the option is being resolved.

Ignore not defined Options
~~~~~~~~~~~~~~~~~~~~~~~~~~

By default, all options are resolved, validated and an :class:`Symfony\\Component\\OptionsResolver\\Exception\\UndefinedOptionsException`
is thrown if an unknown option is passed. You can ignore not defined options by using the
:method:`Symfony\\Component\\OptionsResolver\\OptionsResolver::ignoreUndefined` method::

// ...
$resolver
->setDefined(['hostname'])
->setIgnoreUndefined(true)
;

// option "version" will be ignored
$resolver->resolve([
'hostname' => 'acme/package',
'version' => '1.2.3'
]);

.. versionadded:: 6.3

The ``ignoreUndefined`` method was introduced in Symfony 6.3.

Chaining Option Configurations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down