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
* 4.4: (21 commits)
[appveyor] exclude tty group
[HttpFoundation] Add types to private/final/internal methods and constructors.
Add types to private/final/internal methods and constructors.
SCA: minor code tweaks
Tweak output
[FrameworkBundle] Added --sort option for TranslationUpdateCommand
[HttpClient] fallbackto CURLMOPT_MAXCONNECTS when CURLMOPT_MAX_HOST_CONNECTIONS is not available
[DI] generate preload.php file for PHP 7.4 in cache folder
Allow version 2 of the contracts package.
[Serializer] Allow multi-dimenstion object array in AbstractObjectNormalizer
fixed typo
[HttpKernel] Fix Apache mod_expires Session Cache-Control issue
deprecated not passing dash symbol (-) to STDIN commands
[VarDumper] display ellipsed FQCN for nested classes
[VarDumper] Display fully qualified title
[Mailer] Change the syntax for DSNs using failover or roundrobin
Removed workaround introduced in 4.3
[Console] Added support for definition list
[OptionsResolver] Display full nested options hierarchy in exceptions
New welcome page
...
Copy file name to clipboardExpand all lines: OptionsResolver.php
+38-18Lines changed: 38 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -103,6 +103,8 @@ class OptionsResolver implements Options
103
103
*/
104
104
private$locked = false;
105
105
106
+
private$parentsOptions = [];
107
+
106
108
privatestatic$typeAliases = [
107
109
'boolean' => 'bool',
108
110
'integer' => 'int',
@@ -423,7 +425,7 @@ public function setDeprecated(string $option, $deprecationMessage = 'The option
423
425
}
424
426
425
427
if (!isset($this->defined[$option])) {
426
-
thrownewUndefinedOptionsException(sprintf('The option "%s" does not exist, defined options are: "%s".', $option, implode('", "', array_keys($this->defined))));
428
+
thrownewUndefinedOptionsException(sprintf('The option "%s" does not exist, defined options are: "%s".', $this->formatOptions([$option]), implode('", "', array_keys($this->defined))));
427
429
}
428
430
429
431
if (!\is_string($deprecationMessage) && !$deprecationMessageinstanceof \Closure) {
@@ -481,7 +483,7 @@ public function setNormalizer(string $option, \Closure $normalizer)
481
483
}
482
484
483
485
if (!isset($this->defined[$option])) {
484
-
thrownewUndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined))));
486
+
thrownewUndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $this->formatOptions([$option]), implode('", "', array_keys($this->defined))));
485
487
}
486
488
487
489
$this->normalizers[$option] = [$normalizer];
@@ -526,7 +528,7 @@ public function addNormalizer(string $option, \Closure $normalizer, bool $forceP
526
528
}
527
529
528
530
if (!isset($this->defined[$option])) {
529
-
thrownewUndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined))));
531
+
thrownewUndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $this->formatOptions([$option]), implode('", "', array_keys($this->defined))));
530
532
}
531
533
532
534
if ($forcePrepend) {
@@ -569,7 +571,7 @@ public function setAllowedValues(string $option, $allowedValues)
569
571
}
570
572
571
573
if (!isset($this->defined[$option])) {
572
-
thrownewUndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined))));
574
+
thrownewUndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $this->formatOptions([$option]), implode('", "', array_keys($this->defined))));
@@ -610,7 +612,7 @@ public function addAllowedValues(string $option, $allowedValues)
610
612
}
611
613
612
614
if (!isset($this->defined[$option])) {
613
-
thrownewUndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined))));
615
+
thrownewUndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $this->formatOptions([$option]), implode('", "', array_keys($this->defined))));
614
616
}
615
617
616
618
if (!\is_array($allowedValues)) {
@@ -651,7 +653,7 @@ public function setAllowedTypes(string $option, $allowedTypes)
651
653
}
652
654
653
655
if (!isset($this->defined[$option])) {
654
-
thrownewUndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined))));
656
+
thrownewUndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $this->formatOptions([$option]), implode('", "', array_keys($this->defined))));
@@ -686,7 +688,7 @@ public function addAllowedTypes(string $option, $allowedTypes)
686
688
}
687
689
688
690
if (!isset($this->defined[$option])) {
689
-
thrownewUndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined))));
691
+
thrownewUndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $this->formatOptions([$option]), implode('", "', array_keys($this->defined))));
690
692
}
691
693
692
694
if (!isset($this->allowedTypes[$option])) {
@@ -793,7 +795,7 @@ public function resolve(array $options = [])
793
795
ksort($clone->defined);
794
796
ksort($diff);
795
797
796
-
thrownewUndefinedOptionsException(sprintf((\count($diff) > 1 ? 'The options "%s" do not exist.' : 'The option "%s" does not exist.').' Defined options are: "%s".', implode('", "', array_keys($diff)), implode('", "', array_keys($clone->defined))));
798
+
thrownewUndefinedOptionsException(sprintf((\count($diff) > 1 ? 'The options "%s" do not exist.' : 'The option "%s" does not exist.').' Defined options are: "%s".', $this->formatOptions(array_keys($diff)), implode('", "', array_keys($clone->defined))));
797
799
}
798
800
799
801
// Override options set by the user
@@ -809,7 +811,7 @@ public function resolve(array $options = [])
809
811
if (\count($diff) > 0) {
810
812
ksort($diff);
811
813
812
-
thrownewMissingOptionsException(sprintf(\count($diff) > 1 ? 'The required options "%s" are missing.' : 'The required option "%s" is missing.', implode('", "', array_keys($diff))));
814
+
thrownewMissingOptionsException(sprintf(\count($diff) > 1 ? 'The required options "%s" are missing.' : 'The required option "%s" is missing.', $this->formatOptions(array_keys($diff))));
813
815
}
814
816
815
817
// Lock the container
@@ -858,10 +860,10 @@ public function offsetGet($option, bool $triggerDeprecation = true)
858
860
// Check whether the option is set at all
859
861
if (!isset($this->defaults[$option]) && !\array_key_exists($option, $this->defaults)) {
860
862
if (!isset($this->defined[$option])) {
861
-
thrownewNoSuchOptionException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined))));
863
+
thrownewNoSuchOptionException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $this->formatOptions([$option]), implode('", "', array_keys($this->defined))));
862
864
}
863
865
864
-
thrownewNoSuchOptionException(sprintf('The optional option "%s" has no value set. You should make sure it is set with "isset" before reading it.', $option));
866
+
thrownewNoSuchOptionException(sprintf('The optional option "%s" has no value set. You should make sure it is set with "isset" before reading it.', $this->formatOptions([$option])));
865
867
}
866
868
867
869
$value = $this->defaults[$option];
@@ -870,17 +872,19 @@ public function offsetGet($option, bool $triggerDeprecation = true)
870
872
if (isset($this->nested[$option])) {
871
873
// If the closure is already being called, we have a cyclic dependency
872
874
if (isset($this->calling[$option])) {
873
-
thrownewOptionDefinitionException(sprintf('The options "%s" have a cyclic dependency.', implode('", "', array_keys($this->calling))));
875
+
thrownewOptionDefinitionException(sprintf('The options "%s" have a cyclic dependency.', $this->formatOptions(array_keys($this->calling))));
874
876
}
875
877
876
878
if (!\is_array($value)) {
877
-
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)));
879
+
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), $this->formatTypeOf($value)));
878
880
}
879
881
880
882
// The following section must be protected from cyclic calls.
@@ -895,7 +899,7 @@ public function offsetGet($option, bool $triggerDeprecation = true)
895
899
// If the closure is already being called, we have a cyclic
896
900
// dependency
897
901
if (isset($this->calling[$option])) {
898
-
thrownewOptionDefinitionException(sprintf('The options "%s" have a cyclic dependency.', implode('", "', array_keys($this->calling))));
902
+
thrownewOptionDefinitionException(sprintf('The options "%s" have a cyclic dependency.', $this->formatOptions(array_keys($this->calling))));
899
903
}
900
904
901
905
// The following section must be protected from cyclic
@@ -930,10 +934,10 @@ public function offsetGet($option, bool $triggerDeprecation = true)
930
934
$keys = array_keys($invalidTypes);
931
935
932
936
if (1 === \count($keys) && '[]' === substr($keys[0], -2)) {
933
-
thrownewInvalidOptionsException(sprintf('The option "%s" with value %s is expected to be of type "%s", but one of the elements is of type "%s".', $option, $this->formatValue($value), implode('" or "', $this->allowedTypes[$option]), $keys[0]));
937
+
thrownewInvalidOptionsException(sprintf('The option "%s" with value %s is expected to be of type "%s", but one of the elements is of type "%s".', $this->formatOptions([$option]), $this->formatValue($value), implode('" or "', $this->allowedTypes[$option]), $keys[0]));
934
938
}
935
939
936
-
thrownewInvalidOptionsException(sprintf('The option "%s" with value %s is expected to be of type "%s", but is of type "%s".', $option, $this->formatValue($value), implode('" or "', $this->allowedTypes[$option]), implode('|', array_keys($invalidTypes))));
940
+
thrownewInvalidOptionsException(sprintf('The option "%s" with value %s is expected to be of type "%s", but is of type "%s".', $this->formatOptions([$option]), $this->formatValue($value), implode('" or "', $this->allowedTypes[$option]), implode('|', array_keys($invalidTypes))));
937
941
}
938
942
}
939
943
@@ -987,7 +991,7 @@ public function offsetGet($option, bool $triggerDeprecation = true)
987
991
if ($deprecationMessageinstanceof \Closure) {
988
992
// If the closure is already being called, we have a cyclic dependency
989
993
if (isset($this->calling[$option])) {
990
-
thrownewOptionDefinitionException(sprintf('The options "%s" have a cyclic dependency.', implode('", "', array_keys($this->calling))));
994
+
thrownewOptionDefinitionException(sprintf('The options "%s" have a cyclic dependency.', $this->formatOptions(array_keys($this->calling))));
991
995
}
992
996
993
997
$this->calling[$option] = true;
@@ -1010,7 +1014,7 @@ public function offsetGet($option, bool $triggerDeprecation = true)
1010
1014
// If the closure is already being called, we have a cyclic
1011
1015
// dependency
1012
1016
if (isset($this->calling[$option])) {
1013
-
thrownewOptionDefinitionException(sprintf('The options "%s" have a cyclic dependency.', implode('", "', array_keys($this->calling))));
1017
+
thrownewOptionDefinitionException(sprintf('The options "%s" have a cyclic dependency.', $this->formatOptions(array_keys($this->calling))));
1014
1018
}
1015
1019
1016
1020
// The following section must be protected from cyclic
@@ -1193,4 +1197,20 @@ private function formatValues(array $values): string
0 commit comments