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
Copy file name to clipboardExpand all lines: src/Symfony/Component/OptionsResolver/OptionsResolver.php
+53-1
Original file line number
Diff line number
Diff line change
@@ -71,6 +71,11 @@ class OptionsResolver implements Options
71
71
*/
72
72
private$allowedTypes = [];
73
73
74
+
/**
75
+
* A list of info messages for each option.
76
+
*/
77
+
private$info = [];
78
+
74
79
/**
75
80
* A list of closures for evaluating lazy options.
76
81
*/
@@ -715,6 +720,48 @@ public function define(string $option): OptionConfigurator
715
720
returnnewOptionConfigurator($option, $this);
716
721
}
717
722
723
+
/**
724
+
* Sets an info message for an option.
725
+
*
726
+
* @param string $option The option name
727
+
* @param string $info The info message
728
+
*
729
+
* @return $this
730
+
*
731
+
* @throws UndefinedOptionsException If the option is undefined
732
+
* @throws AccessException If called from a lazy option or normalizer
733
+
*/
734
+
publicfunctionsetInfo(string$option, string$info)
735
+
{
736
+
if ($this->locked) {
737
+
thrownewAccessException('The Info message cannot be set from a lazy option or normalizer.');
738
+
}
739
+
740
+
if (!isset($this->defined[$option])) {
741
+
thrownewUndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $this->formatOptions([$option]), implode('", "', array_keys($this->defined))));
742
+
}
743
+
744
+
$this->info[$option] = $info;
745
+
746
+
return$this;
747
+
}
748
+
749
+
/**
750
+
* Gets the info message for an option.
751
+
*
752
+
* @param string $option The option name
753
+
*
754
+
* @return string|null The info message of the given option
755
+
*/
756
+
publicfunctiongetInfo(string$option): ?string
757
+
{
758
+
if (!isset($this->defined[$option])) {
759
+
thrownewUndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $this->formatOptions([$option]), implode('", "', array_keys($this->defined))));
760
+
}
761
+
762
+
return$this->info[$option] ?? null;
763
+
}
764
+
718
765
/**
719
766
* Removes the option with the given name.
720
767
*
@@ -734,7 +781,7 @@ public function remove($optionNames)
0 commit comments