You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
trigger_deprecation('symfony/options-resolver', '7.3', 'Defining nested options via "%s()" is deprecated and will be removed in Symfony 8.0, use "setNested()" method instead.', __METHOD__);
236
+
$this->deprecatedNested[$option] = true;
237
+
236
238
// Store closure for later evaluation
237
239
$this->nested[$option][] = $value;
238
240
$this->defaults[$option] = [];
@@ -245,8 +247,13 @@ public function setDefault(string $option, mixed $value): static
thrownewInvalidArgumentException(\sprintf('Argument 2 passed to "%s()" must be a \Closure where the first argument is of type "%s" and the second argument is of type "%s".', __METHOD__, __CLASS__, Options::class));
431
+
}
432
+
433
+
// Store closure for later evaluation
434
+
$this->nested[$option][] = $nested;
435
+
$this->defaults[$option] = [];
436
+
$this->defined[$option] = true;
437
+
438
+
// Make sure the option is processed
439
+
unset($this->resolved[$option]);
440
+
441
+
return$this;
442
+
}
443
+
406
444
publicfunctionisNested(string$option): bool
407
445
{
408
446
returnisset($this->nested[$option]);
@@ -947,6 +985,29 @@ public function offsetGet(mixed $option, bool $triggerDeprecation = true): mixed
947
985
948
986
$value = $this->defaults[$option];
949
987
988
+
// Resolve the option if the default value is lazily evaluated
989
+
if (isset($this->lazy[$option])) {
990
+
// If the closure is already being called, we have a cyclic
991
+
// dependency
992
+
if (isset($this->calling[$option])) {
993
+
thrownewOptionDefinitionException(\sprintf('The options "%s" have a cyclic dependency.', $this->formatOptions(array_keys($this->calling))));
994
+
}
995
+
996
+
// The following section must be protected from cyclic
997
+
// calls. Set $calling for the current $option to detect a cyclic
998
+
// dependency
999
+
// BEGIN
1000
+
$this->calling[$option] = true;
1001
+
try {
1002
+
foreach ($this->lazy[$option] as$closure) {
1003
+
$value = $closure($this, $value);
1004
+
}
1005
+
} finally {
1006
+
unset($this->calling[$option]);
1007
+
}
1008
+
// END
1009
+
}
1010
+
950
1011
// Resolve the option if it is a nested definition
951
1012
if (isset($this->nested[$option])) {
952
1013
// If the closure is already being called, we have a cyclic dependency
@@ -989,29 +1050,6 @@ public function offsetGet(mixed $option, bool $triggerDeprecation = true): mixed
989
1050
}
990
1051
}
991
1052
992
-
// Resolve the option if the default value is lazily evaluated
993
-
if (isset($this->lazy[$option])) {
994
-
// If the closure is already being called, we have a cyclic
995
-
// dependency
996
-
if (isset($this->calling[$option])) {
997
-
thrownewOptionDefinitionException(\sprintf('The options "%s" have a cyclic dependency.', $this->formatOptions(array_keys($this->calling))));
998
-
}
999
-
1000
-
// The following section must be protected from cyclic
1001
-
// calls. Set $calling for the current $option to detect a cyclic
0 commit comments