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
// Yet undefined options can be marked as resolved, because we only need
175
194
// to resolve options with lazy closures, normalizers or validation
@@ -614,6 +633,7 @@ public function clear()
614
633
615
634
$this->defined = array();
616
635
$this->defaults = array();
636
+
$this->nested = array();
617
637
$this->required = array();
618
638
$this->resolved = array();
619
639
$this->lazy = array();
@@ -745,6 +765,36 @@ public function offsetGet($option)
745
765
746
766
$value = $this->defaults[$option];
747
767
768
+
// Resolve the option if the default value is nested
769
+
if (isset($this->nested[$option])) {
770
+
// If the closure is already being called, we have a cyclic
771
+
// dependency
772
+
if (isset($this->calling[$option])) {
773
+
thrownewOptionDefinitionException(sprintf('The options "%s" have a cyclic dependency.', implode('", "', array_keys($this->calling))));
774
+
}
775
+
776
+
// Nested values must be an array
777
+
if (!\is_array($value)) {
778
+
thrownewInvalidOptionsException(sprintf('The nested option "%s" with value %s is expected to be of type array, but is of type "%s".', $option, $this->formatValue($value), $this->formatTypeOf($value, 'array')));
779
+
}
780
+
781
+
// The following section must be protected from cyclic
782
+
// calls. Set $calling for the current $option to detect a cyclic
783
+
// dependency
784
+
// BEGIN
785
+
$this->calling[$option] = true;
786
+
try {
787
+
$resolver = newself();
788
+
foreach ($this->nested[$option] as$closure) {
789
+
$closure($resolver, $this);
790
+
}
791
+
$value = $resolver->resolve($value);
792
+
} finally {
793
+
unset($this->calling[$option]);
794
+
}
795
+
// END
796
+
}
797
+
748
798
// Resolve the option if the default value is lazily evaluated
749
799
if (isset($this->lazy[$option])) {
750
800
// If the closure is already being called, we have a cyclic
0 commit comments