OptionsResolver::setDefaults()

OptionsResolver setDefaults(array $defaults) Sets a list of default values. Parameters array $defaults The default values to set Return Value OptionsResolver This instance Exceptions AccessException If called from a lazy option or normalizer

OptionsResolver::setDefault()

OptionsResolver setDefault(string $option, mixed $value) Sets the default value of a given option. If the default value should be set based on other options, you can pass a closure with the following signature: function (Options $options) { // ... } The closure will be evaluated when {@link resolve()} is called. The closure has access to the resolved values of other options through the passed {@link Options} instance: function (Options $options) { if (isset($options['po

OptionsResolver::setAllowedValues()

OptionsResolver setAllowedValues(string $option, mixed $allowedValues) Sets allowed values for an option. Instead of passing values, you may also pass a closures with the following signature: function ($value) { // return true or false } The closure receives the value as argument and should return true to accept the value and false to reject the value. Parameters string $option The option name mixed $allowedValues One or more acceptable values/closures Return Value Option

OptionsResolver::setAllowedTypes()

OptionsResolver setAllowedTypes(string $option, string|string[] $allowedTypes) Sets allowed types for an option. Any type for which a corresponding is_() function exists is acceptable. Additionally, fully-qualified class or interface names may be passed. Parameters string $option The option name string|string[] $allowedTypes One or more accepted types Return Value OptionsResolver This instance Exceptions UndefinedOptionsException If the option is undefined AccessException If c

OptionsResolver::resolve()

array resolve(array $options = array()) Merges options with the default values stored in the container and validates them. Exceptions are thrown if: Undefined options are passed; Required options are missing; Options have invalid types; Options have invalid values. Parameters array $options A map of option names to values Return Value array The merged and validated options Exceptions UndefinedOptionsException If an option name is undefined InvalidOptionsException If an option d

OptionsResolver::remove()

OptionsResolver remove(string|string[] $optionNames) Removes the option with the given name. Undefined options are ignored. Parameters string|string[] $optionNames One or more option names Return Value OptionsResolver This instance Exceptions AccessException If called from a lazy option or normalizer

OptionsResolver::offsetUnset()

offsetUnset($option) Not supported. Parameters $option Exceptions AccessException

OptionsResolver::offsetSet()

offsetSet($option, $value) Not supported. Parameters $option $value Exceptions AccessException

OptionsResolver::offsetGet()

mixed offsetGet(string $option) Returns the resolved value of an option. Parameters string $option The option name Return Value mixed The option value Exceptions AccessException If accessing this method outside of {@link resolve()} NoSuchOptionException If the option is not set InvalidOptionsException If the option doesn't fulfill the specified validation rules OptionDefinitionException If there is a cyclic dependency between lazy options and/or normalizers

OptionsResolver::offsetExists()

bool offsetExists(string $option) Returns whether a resolved option with the given name exists. Parameters string $option The option name Return Value bool Whether the option is set Exceptions AccessException If accessing this method outside of {@link resolve()} See also \ArrayAccess::offsetExists()