diff --git a/src/Symfony/Component/OptionsResolver/CHANGELOG.md b/src/Symfony/Component/OptionsResolver/CHANGELOG.md index 60ea43f7ec20c..9abbe5b99cdab 100644 --- a/src/Symfony/Component/OptionsResolver/CHANGELOG.md +++ b/src/Symfony/Component/OptionsResolver/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +5.0.0 +----- + + * added `offsetGet()` method to the `Options` interface with a new boolean argument `$triggerDeprecation` + 4.3.0 ----- diff --git a/src/Symfony/Component/OptionsResolver/Options.php b/src/Symfony/Component/OptionsResolver/Options.php index d18374cb91f6b..752849dcce1e2 100644 --- a/src/Symfony/Component/OptionsResolver/Options.php +++ b/src/Symfony/Component/OptionsResolver/Options.php @@ -11,14 +11,34 @@ namespace Symfony\Component\OptionsResolver; +use Symfony\Component\OptionsResolver\Exception\AccessException; +use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; +use Symfony\Component\OptionsResolver\Exception\NoSuchOptionException; +use Symfony\Component\OptionsResolver\Exception\OptionDefinitionException; + /** * Contains resolved option values. * * @author Bernhard Schussek * @author Tobias Schultze - * - * @method mixed offsetGet(string $option, bool $triggerDeprecation = true) */ interface Options extends \ArrayAccess, \Countable { + /** + * Returns the resolved value of an option. + * + * @param string $option The option name + * @param bool $triggerDeprecation Whether to trigger the deprecation or not + * + * @return mixed The option value + * + * @throws AccessException If accessing this method outside of + * {@link resolve()} + * @throws NoSuchOptionException If the option is not set + * @throws InvalidOptionsException If the option doesn't fulfill the + * specified validation rules + * @throws OptionDefinitionException If there is a cyclic dependency between + * lazy options and/or normalizers + */ + public function offsetGet($option, bool $triggerDeprecation = true); } diff --git a/src/Symfony/Component/OptionsResolver/OptionsResolver.php b/src/Symfony/Component/OptionsResolver/OptionsResolver.php index 0e68e75ff83ce..0626e487b3ff6 100644 --- a/src/Symfony/Component/OptionsResolver/OptionsResolver.php +++ b/src/Symfony/Component/OptionsResolver/OptionsResolver.php @@ -825,29 +825,14 @@ public function resolve(array $options = []) } /** - * Returns the resolved value of an option. - * - * @param string $option The option name - * @param bool $triggerDeprecation Whether to trigger the deprecation or not (true by default) - * - * @return mixed The option value - * - * @throws AccessException If accessing this method outside of - * {@link resolve()} - * @throws NoSuchOptionException If the option is not set - * @throws InvalidOptionsException If the option doesn't fulfill the - * specified validation rules - * @throws OptionDefinitionException If there is a cyclic dependency between - * lazy options and/or normalizers + * {@inheritdoc} */ - public function offsetGet($option/*, bool $triggerDeprecation = true*/) + public function offsetGet($option, bool $triggerDeprecation = true) { if (!$this->locked) { throw new AccessException('Array access is only supported within closures of lazy options and normalizers.'); } - $triggerDeprecation = 1 === \func_num_args() || \func_get_arg(1); - // Shortcut for resolved options if (isset($this->resolved[$option]) || \array_key_exists($option, $this->resolved)) { if ($triggerDeprecation && isset($this->deprecated[$option]) && (isset($this->given[$option]) || $this->calling) && \is_string($this->deprecated[$option])) {