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,35 @@ 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
+
// The following section must be protected from cyclic
777
+
// calls. Set $calling for the current $option to detect a cyclic
778
+
// dependency
779
+
// BEGIN
780
+
$this->calling[$option] = true;
781
+
try {
782
+
if (!\is_array($value)) {
783
+
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')));
784
+
}
785
+
786
+
$resolver = newself();
787
+
foreach ($this->nested[$option] as$closure) {
788
+
$closure($resolver, $this);
789
+
}
790
+
$value = $resolver->resolve($value);
791
+
} finally {
792
+
unset($this->calling[$option]);
793
+
}
794
+
// END
795
+
}
796
+
748
797
// Resolve the option if the default value is lazily evaluated
749
798
if (isset($this->lazy[$option])) {
750
799
// If the closure is already being called, we have a cyclic
0 commit comments