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 "setOptions()" 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
thrownewAccessException('Nested options cannot be defined from a lazy option or normalizer.');
424
+
}
425
+
426
+
// Store closure for later evaluation
427
+
$this->nested[$option][] = $nested;
428
+
$this->defaults[$option] = [];
429
+
$this->defined[$option] = true;
430
+
431
+
// Make sure the option is processed
432
+
unset($this->resolved[$option]);
433
+
434
+
return$this;
435
+
}
436
+
406
437
publicfunctionisNested(string$option): bool
407
438
{
408
439
returnisset($this->nested[$option]);
@@ -947,6 +978,23 @@ public function offsetGet(mixed $option, bool $triggerDeprecation = true): mixed
947
978
948
979
$value = $this->defaults[$option];
949
980
981
+
// Resolve the option if the default value is lazily evaluated
982
+
if (isset($this->lazy[$option])) {
983
+
// If the closure is already being called, we have a cyclic dependency
984
+
if (isset($this->calling[$option])) {
985
+
thrownewOptionDefinitionException(\sprintf('The options "%s" have a cyclic dependency.', $this->formatOptions(array_keys($this->calling))));
986
+
}
987
+
988
+
$this->calling[$option] = true;
989
+
try {
990
+
foreach ($this->lazy[$option] as$closure) {
991
+
$value = $closure($this, $value);
992
+
}
993
+
} finally {
994
+
unset($this->calling[$option]);
995
+
}
996
+
}
997
+
950
998
// Resolve the option if it is a nested definition
951
999
if (isset($this->nested[$option])) {
952
1000
// If the closure is already being called, we have a cyclic dependency
@@ -958,7 +1006,6 @@ public function offsetGet(mixed $option, bool $triggerDeprecation = true): mixed
958
1006
thrownewInvalidOptionsException(\sprintf('The nested option "%s" with value %s is expected to be of type array, but is of type "%s".', $this->formatOptions([$option]), $this->formatValue($value), get_debug_type($value)));
959
1007
}
960
1008
961
-
// The following section must be protected from cyclic calls.
962
1009
$this->calling[$option] = true;
963
1010
try {
964
1011
$resolver = newself();
@@ -989,29 +1036,6 @@ public function offsetGet(mixed $option, bool $triggerDeprecation = true): mixed
989
1036
}
990
1037
}
991
1038
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