Skip to content

Commit 9cebb5b

Browse files
Merge branch '4.1'
* 4.1: [DI] configure inlined services before injecting them when dumping the container Consistently throw exceptions on a single line fix fopen calls Update .editorconfig
2 parents a3d9204 + b4e6119 commit 9cebb5b

File tree

1 file changed

+11
-51
lines changed

1 file changed

+11
-51
lines changed

OptionsResolver.php

Lines changed: 11 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -438,11 +438,7 @@ public function setNormalizer($option, \Closure $normalizer)
438438
}
439439

440440
if (!isset($this->defined[$option])) {
441-
throw new UndefinedOptionsException(sprintf(
442-
'The option "%s" does not exist. Defined options are: "%s".',
443-
$option,
444-
implode('", "', array_keys($this->defined))
445-
));
441+
throw new UndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined))));
446442
}
447443

448444
$this->normalizers[$option] = $normalizer;
@@ -481,11 +477,7 @@ public function setAllowedValues($option, $allowedValues)
481477
}
482478

483479
if (!isset($this->defined[$option])) {
484-
throw new UndefinedOptionsException(sprintf(
485-
'The option "%s" does not exist. Defined options are: "%s".',
486-
$option,
487-
implode('", "', array_keys($this->defined))
488-
));
480+
throw new UndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined))));
489481
}
490482

491483
$this->allowedValues[$option] = \is_array($allowedValues) ? $allowedValues : array($allowedValues);
@@ -526,11 +518,7 @@ public function addAllowedValues($option, $allowedValues)
526518
}
527519

528520
if (!isset($this->defined[$option])) {
529-
throw new UndefinedOptionsException(sprintf(
530-
'The option "%s" does not exist. Defined options are: "%s".',
531-
$option,
532-
implode('", "', array_keys($this->defined))
533-
));
521+
throw new UndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined))));
534522
}
535523

536524
if (!\is_array($allowedValues)) {
@@ -571,11 +559,7 @@ public function setAllowedTypes($option, $allowedTypes)
571559
}
572560

573561
if (!isset($this->defined[$option])) {
574-
throw new UndefinedOptionsException(sprintf(
575-
'The option "%s" does not exist. Defined options are: "%s".',
576-
$option,
577-
implode('", "', array_keys($this->defined))
578-
));
562+
throw new UndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined))));
579563
}
580564

581565
$this->allowedTypes[$option] = (array) $allowedTypes;
@@ -610,11 +594,7 @@ public function addAllowedTypes($option, $allowedTypes)
610594
}
611595

612596
if (!isset($this->defined[$option])) {
613-
throw new UndefinedOptionsException(sprintf(
614-
'The option "%s" does not exist. Defined options are: "%s".',
615-
$option,
616-
implode('", "', array_keys($this->defined))
617-
));
597+
throw new UndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined))));
618598
}
619599

620600
if (!isset($this->allowedTypes[$option])) {
@@ -720,11 +700,7 @@ public function resolve(array $options = array())
720700
ksort($clone->defined);
721701
ksort($diff);
722702

723-
throw new UndefinedOptionsException(sprintf(
724-
(\count($diff) > 1 ? 'The options "%s" do not exist.' : 'The option "%s" does not exist.').' Defined options are: "%s".',
725-
implode('", "', array_keys($diff)),
726-
implode('", "', array_keys($clone->defined))
727-
));
703+
throw new UndefinedOptionsException(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))));
728704
}
729705

730706
// Override options set by the user
@@ -739,10 +715,7 @@ public function resolve(array $options = array())
739715
if (\count($diff) > 0) {
740716
ksort($diff);
741717

742-
throw new MissingOptionsException(sprintf(
743-
\count($diff) > 1 ? 'The required options "%s" are missing.' : 'The required option "%s" is missing.',
744-
implode('", "', array_keys($diff))
745-
));
718+
throw new MissingOptionsException(sprintf(\count($diff) > 1 ? 'The required options "%s" are missing.' : 'The required option "%s" is missing.', implode('", "', array_keys($diff))));
746719
}
747720

748721
// Lock the container
@@ -786,17 +759,10 @@ public function offsetGet($option)
786759
// Check whether the option is set at all
787760
if (!array_key_exists($option, $this->defaults)) {
788761
if (!isset($this->defined[$option])) {
789-
throw new NoSuchOptionException(sprintf(
790-
'The option "%s" does not exist. Defined options are: "%s".',
791-
$option,
792-
implode('", "', array_keys($this->defined))
793-
));
762+
throw new NoSuchOptionException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined))));
794763
}
795764

796-
throw new NoSuchOptionException(sprintf(
797-
'The optional option "%s" has no value set. You should make sure it is set with "isset" before reading it.',
798-
$option
799-
));
765+
throw new NoSuchOptionException(sprintf('The optional option "%s" has no value set. You should make sure it is set with "isset" before reading it.', $option));
800766
}
801767

802768
$value = $this->defaults[$option];
@@ -806,10 +772,7 @@ public function offsetGet($option)
806772
// If the closure is already being called, we have a cyclic
807773
// dependency
808774
if (isset($this->calling[$option])) {
809-
throw new OptionDefinitionException(sprintf(
810-
'The options "%s" have a cyclic dependency.',
811-
implode('", "', array_keys($this->calling))
812-
));
775+
throw new OptionDefinitionException(sprintf('The options "%s" have a cyclic dependency.', implode('", "', array_keys($this->calling))));
813776
}
814777

815778
// The following section must be protected from cyclic
@@ -909,10 +872,7 @@ public function offsetGet($option)
909872
// If the closure is already being called, we have a cyclic
910873
// dependency
911874
if (isset($this->calling[$option])) {
912-
throw new OptionDefinitionException(sprintf(
913-
'The options "%s" have a cyclic dependency.',
914-
implode('", "', array_keys($this->calling))
915-
));
875+
throw new OptionDefinitionException(sprintf('The options "%s" have a cyclic dependency.', implode('", "', array_keys($this->calling))));
916876
}
917877

918878
$normalizer = $this->normalizers[$option];

0 commit comments

Comments
 (0)