Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b8cd9ba

Browse filesBrowse files
committed
Add $triggerDeprecation arg to offsetGet() method in Options interface
1 parent 4a437ab commit b8cd9ba
Copy full SHA for b8cd9ba

File tree

3 files changed

+29
-19
lines changed
Filter options

3 files changed

+29
-19
lines changed

‎src/Symfony/Component/OptionsResolver/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/OptionsResolver/CHANGELOG.md
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
5.0.0
5+
-----
6+
7+
* added `offsetGet()` method to the `Options` interface with a new boolean argument `$triggerDeprecation`
8+
49
4.3.0
510
-----
611

‎src/Symfony/Component/OptionsResolver/Options.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/OptionsResolver/Options.php
+22-2Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,34 @@
1111

1212
namespace Symfony\Component\OptionsResolver;
1313

14+
use Symfony\Component\OptionsResolver\Exception\AccessException;
15+
use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException;
16+
use Symfony\Component\OptionsResolver\Exception\NoSuchOptionException;
17+
use Symfony\Component\OptionsResolver\Exception\OptionDefinitionException;
18+
1419
/**
1520
* Contains resolved option values.
1621
*
1722
* @author Bernhard Schussek <bschussek@gmail.com>
1823
* @author Tobias Schultze <http://tobion.de>
19-
*
20-
* @method mixed offsetGet(string $option, bool $triggerDeprecation = true)
2124
*/
2225
interface Options extends \ArrayAccess, \Countable
2326
{
27+
/**
28+
* Returns the resolved value of an option.
29+
*
30+
* @param string $option The option name
31+
* @param bool $triggerDeprecation Whether to trigger the deprecation or not
32+
*
33+
* @return mixed The option value
34+
*
35+
* @throws AccessException If accessing this method outside of
36+
* {@link resolve()}
37+
* @throws NoSuchOptionException If the option is not set
38+
* @throws InvalidOptionsException If the option doesn't fulfill the
39+
* specified validation rules
40+
* @throws OptionDefinitionException If there is a cyclic dependency between
41+
* lazy options and/or normalizers
42+
*/
43+
public function offsetGet($option, bool $triggerDeprecation = true);
2444
}

‎src/Symfony/Component/OptionsResolver/OptionsResolver.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/OptionsResolver/OptionsResolver.php
+2-17Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -825,29 +825,14 @@ public function resolve(array $options = [])
825825
}
826826

827827
/**
828-
* Returns the resolved value of an option.
829-
*
830-
* @param string $option The option name
831-
* @param bool $triggerDeprecation Whether to trigger the deprecation or not (true by default)
832-
*
833-
* @return mixed The option value
834-
*
835-
* @throws AccessException If accessing this method outside of
836-
* {@link resolve()}
837-
* @throws NoSuchOptionException If the option is not set
838-
* @throws InvalidOptionsException If the option doesn't fulfill the
839-
* specified validation rules
840-
* @throws OptionDefinitionException If there is a cyclic dependency between
841-
* lazy options and/or normalizers
828+
* {@inheritdoc}
842829
*/
843-
public function offsetGet($option/*, bool $triggerDeprecation = true*/)
830+
public function offsetGet($option, bool $triggerDeprecation = true)
844831
{
845832
if (!$this->locked) {
846833
throw new AccessException('Array access is only supported within closures of lazy options and normalizers.');
847834
}
848835

849-
$triggerDeprecation = 1 === \func_num_args() || \func_get_arg(1);
850-
851836
// Shortcut for resolved options
852837
if (isset($this->resolved[$option]) || \array_key_exists($option, $this->resolved)) {
853838
if ($triggerDeprecation && isset($this->deprecated[$option]) && (isset($this->given[$option]) || $this->calling) && \is_string($this->deprecated[$option])) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.