11
11
12
12
namespace Symfony \Component \OptionsResolver ;
13
13
14
- use ArrayAccess ;
15
- use Closure ;
16
- use Iterator ;
17
- use OutOfBoundsException ;
18
- use Countable ;
19
14
use Symfony \Component \OptionsResolver \Exception \OptionDefinitionException ;
20
15
21
16
/**
22
17
* Container for resolving inter-dependent options.
23
18
*
24
19
* @author Bernhard Schussek <[email protected] >
25
20
*/
26
- class Options implements ArrayAccess, Iterator, Countable
21
+ class Options implements \ ArrayAccess, \ Iterator, \ Countable
27
22
{
28
23
/**
29
24
* A list of option values and LazyOption instances.
@@ -46,9 +41,9 @@ class Options implements ArrayAccess, Iterator, Countable
46
41
/**
47
42
* Whether at least one option has already been read.
48
43
*
49
- * Once reading , the options cannot be changed anymore. This is
44
+ * Once read , the options cannot be changed anymore. This is
50
45
* necessary in order to avoid inconsistencies during the resolving
51
- * process. If any option is changed after reading , all evaluated
46
+ * process. If any option is changed after being read , all evaluated
52
47
* lazy options that depend on this option would become invalid.
53
48
*
54
49
* @var Boolean
@@ -146,6 +141,10 @@ public function overload($option, $value)
146
141
147
142
$ newValue = $ value ;
148
143
144
+ // Reset lazy flag and locks by default
145
+ unset($ this ->lock [$ option ]);
146
+ unset($ this ->lazy [$ option ]);
147
+
149
148
// If an option is a closure that should be evaluated lazily, store it
150
149
// inside a LazyOption instance.
151
150
if ($ this ->isEvaluatedLazily ($ value )) {
@@ -171,7 +170,7 @@ public function overload($option, $value)
171
170
*
172
171
* @return mixed The option value.
173
172
*
174
- * @throws OutOfBoundsException If the option does not exist.
173
+ * @throws \ OutOfBoundsException If the option does not exist.
175
174
* @throws OptionDefinitionException If a cyclic dependency is detected
176
175
* between two lazy options.
177
176
*/
@@ -180,7 +179,7 @@ public function get($option)
180
179
$ this ->reading = true ;
181
180
182
181
if (!array_key_exists ($ option , $ this ->options )) {
183
- throw new OutOfBoundsException ('The option " ' . $ option . '" does not exist. ' );
182
+ throw new \ OutOfBoundsException ('The option " ' . $ option . '" does not exist. ' );
184
183
}
185
184
186
185
if (isset ($ this ->lazy [$ option ])) {
@@ -268,7 +267,7 @@ public function all()
268
267
*
269
268
* @return Boolean Whether the option exists.
270
269
*
271
- * @see ArrayAccess::offsetExists()
270
+ * @see \ ArrayAccess::offsetExists()
272
271
*/
273
272
public function offsetExists ($ option )
274
273
{
@@ -282,11 +281,11 @@ public function offsetExists($option)
282
281
*
283
282
* @return mixed The option value.
284
283
*
285
- * @throws OutOfBoundsException If the option does not exist.
284
+ * @throws \ OutOfBoundsException If the option does not exist.
286
285
* @throws OptionDefinitionException If a cyclic dependency is detected
287
286
* between two lazy options.
288
287
*
289
- * @see ArrayAccess::offsetGet()
288
+ * @see \ ArrayAccess::offsetGet()
290
289
*/
291
290
public function offsetGet ($ option )
292
291
{
@@ -304,7 +303,7 @@ public function offsetGet($option)
304
303
* Once options are read, the container
305
304
* becomes immutable.
306
305
*
307
- * @see ArrayAccess::offsetSet()
306
+ * @see \ ArrayAccess::offsetSet()
308
307
*/
309
308
public function offsetSet ($ option , $ value )
310
309
{
@@ -320,7 +319,7 @@ public function offsetSet($option, $value)
320
319
* Once options are read, the container
321
320
* becomes immutable.
322
321
*
323
- * @see ArrayAccess::offsetUnset()
322
+ * @see \ ArrayAccess::offsetUnset()
324
323
*/
325
324
public function offsetUnset ($ option )
326
325
{
@@ -418,9 +417,9 @@ private function resolve($option)
418
417
*
419
418
* @return Boolean Whether it is a lazy option closure.
420
419
*/
421
- private static function isEvaluatedLazily ($ value )
420
+ static private function isEvaluatedLazily ($ value )
422
421
{
423
- if (!$ value instanceof Closure) {
422
+ if (!$ value instanceof \ Closure) {
424
423
return false ;
425
424
}
426
425
0 commit comments