Skip to content

Commit b4e6119

Browse files
Merge branch '3.4' into 4.1
* 3.4: [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 464c708 + 994f48b commit b4e6119

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
@@ -381,11 +381,7 @@ public function setNormalizer($option, \Closure $normalizer)
381381
}
382382

383383
if (!isset($this->defined[$option])) {
384-
throw new UndefinedOptionsException(sprintf(
385-
'The option "%s" does not exist. Defined options are: "%s".',
386-
$option,
387-
implode('", "', array_keys($this->defined))
388-
));
384+
throw new UndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined))));
389385
}
390386

391387
$this->normalizers[$option] = $normalizer;
@@ -424,11 +420,7 @@ public function setAllowedValues($option, $allowedValues)
424420
}
425421

426422
if (!isset($this->defined[$option])) {
427-
throw new UndefinedOptionsException(sprintf(
428-
'The option "%s" does not exist. Defined options are: "%s".',
429-
$option,
430-
implode('", "', array_keys($this->defined))
431-
));
423+
throw new UndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined))));
432424
}
433425

434426
$this->allowedValues[$option] = \is_array($allowedValues) ? $allowedValues : array($allowedValues);
@@ -469,11 +461,7 @@ public function addAllowedValues($option, $allowedValues)
469461
}
470462

471463
if (!isset($this->defined[$option])) {
472-
throw new UndefinedOptionsException(sprintf(
473-
'The option "%s" does not exist. Defined options are: "%s".',
474-
$option,
475-
implode('", "', array_keys($this->defined))
476-
));
464+
throw new UndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined))));
477465
}
478466

479467
if (!\is_array($allowedValues)) {
@@ -514,11 +502,7 @@ public function setAllowedTypes($option, $allowedTypes)
514502
}
515503

516504
if (!isset($this->defined[$option])) {
517-
throw new UndefinedOptionsException(sprintf(
518-
'The option "%s" does not exist. Defined options are: "%s".',
519-
$option,
520-
implode('", "', array_keys($this->defined))
521-
));
505+
throw new UndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined))));
522506
}
523507

524508
$this->allowedTypes[$option] = (array) $allowedTypes;
@@ -553,11 +537,7 @@ public function addAllowedTypes($option, $allowedTypes)
553537
}
554538

555539
if (!isset($this->defined[$option])) {
556-
throw new UndefinedOptionsException(sprintf(
557-
'The option "%s" does not exist. Defined options are: "%s".',
558-
$option,
559-
implode('", "', array_keys($this->defined))
560-
));
540+
throw new UndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined))));
561541
}
562542

563543
if (!isset($this->allowedTypes[$option])) {
@@ -662,11 +642,7 @@ public function resolve(array $options = array())
662642
ksort($clone->defined);
663643
ksort($diff);
664644

665-
throw new UndefinedOptionsException(sprintf(
666-
(\count($diff) > 1 ? 'The options "%s" do not exist.' : 'The option "%s" does not exist.').' Defined options are: "%s".',
667-
implode('", "', array_keys($diff)),
668-
implode('", "', array_keys($clone->defined))
669-
));
645+
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))));
670646
}
671647

672648
// Override options set by the user
@@ -681,10 +657,7 @@ public function resolve(array $options = array())
681657
if (\count($diff) > 0) {
682658
ksort($diff);
683659

684-
throw new MissingOptionsException(sprintf(
685-
\count($diff) > 1 ? 'The required options "%s" are missing.' : 'The required option "%s" is missing.',
686-
implode('", "', array_keys($diff))
687-
));
660+
throw new MissingOptionsException(sprintf(\count($diff) > 1 ? 'The required options "%s" are missing.' : 'The required option "%s" is missing.', implode('", "', array_keys($diff))));
688661
}
689662

690663
// Lock the container
@@ -728,17 +701,10 @@ public function offsetGet($option)
728701
// Check whether the option is set at all
729702
if (!array_key_exists($option, $this->defaults)) {
730703
if (!isset($this->defined[$option])) {
731-
throw new NoSuchOptionException(sprintf(
732-
'The option "%s" does not exist. Defined options are: "%s".',
733-
$option,
734-
implode('", "', array_keys($this->defined))
735-
));
704+
throw new NoSuchOptionException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined))));
736705
}
737706

738-
throw new NoSuchOptionException(sprintf(
739-
'The optional option "%s" has no value set. You should make sure it is set with "isset" before reading it.',
740-
$option
741-
));
707+
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));
742708
}
743709

744710
$value = $this->defaults[$option];
@@ -748,10 +714,7 @@ public function offsetGet($option)
748714
// If the closure is already being called, we have a cyclic
749715
// dependency
750716
if (isset($this->calling[$option])) {
751-
throw new OptionDefinitionException(sprintf(
752-
'The options "%s" have a cyclic dependency.',
753-
implode('", "', array_keys($this->calling))
754-
));
717+
throw new OptionDefinitionException(sprintf('The options "%s" have a cyclic dependency.', implode('", "', array_keys($this->calling))));
755718
}
756719

757720
// The following section must be protected from cyclic
@@ -838,10 +801,7 @@ public function offsetGet($option)
838801
// If the closure is already being called, we have a cyclic
839802
// dependency
840803
if (isset($this->calling[$option])) {
841-
throw new OptionDefinitionException(sprintf(
842-
'The options "%s" have a cyclic dependency.',
843-
implode('", "', array_keys($this->calling))
844-
));
804+
throw new OptionDefinitionException(sprintf('The options "%s" have a cyclic dependency.', implode('", "', array_keys($this->calling))));
845805
}
846806

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

0 commit comments

Comments
 (0)