@@ -170,6 +170,21 @@ class Config
170170 */
171171 private $ cliArgs = [];
172172
173+ /**
174+ * A list of valid generators.
175+ *
176+ * {@internal Once support for PHP < 5.6 is dropped, this property should be refactored into a
177+ * class constant.}
178+ *
179+ * @var array<string, string> Keys are the lowercase version of the generator name, while values
180+ * are the associated PHP generator class.
181+ */
182+ private $ validGenerators = [
183+ 'text ' => 'Text ' ,
184+ 'html ' => 'HTML ' ,
185+ 'markdown ' => 'Markdown ' ,
186+ ];
187+
173188 /**
174189 * Command line values that the user has supplied directly.
175190 *
@@ -198,23 +213,6 @@ class Config
198213 */
199214 private static $ executablePaths = [];
200215
201- /**
202- * A list of valid generators.
203- *
204- * - Keys: lowercase version of the generator name.
205- * - Values: name of the generator PHP class.
206- *
207- * Note: once support for PHP < 5.6 is dropped, this property should be refactored into a class
208- * constant.
209- *
210- * @var array<string, string>
211- */
212- private static $ validGenerators = [
213- 'text ' => 'Text ' ,
214- 'html ' => 'HTML ' ,
215- 'markdown ' => 'Markdown ' ,
216- ];
217-
218216
219217 /**
220218 * Get the value of an inaccessible property.
@@ -1235,18 +1233,20 @@ public function processLongArgument($arg, $pos)
12351233 $ generatorName = substr ($ arg , 10 );
12361234 $ lowerCaseGeneratorName = strtolower ($ generatorName );
12371235
1238- if (isset (self ::$ validGenerators [$ lowerCaseGeneratorName ]) === false ) {
1239- $ validOptions = implode (', ' , array_values (self ::$ validGenerators ));
1240- $ error = sprintf (
1241- 'ERROR: "%s" is not a valid generator. Valid options are: %s. ' .PHP_EOL .PHP_EOL ,
1236+ if (isset ($ this ->validGenerators [$ lowerCaseGeneratorName ]) === false ) {
1237+ $ lastOption = array_pop ($ this ->validGenerators );
1238+ $ validOptions = implode (', ' , $ this ->validGenerators );
1239+ $ validOptions .= ' and ' .$ lastOption ;
1240+ $ error = sprintf (
1241+ 'ERROR: "%s" is not a valid generator. The following generators are supported: %s. ' .PHP_EOL .PHP_EOL ,
12421242 $ generatorName ,
12431243 $ validOptions
12441244 );
1245- $ error .= $ this ->printShortUsage (true );
1245+ $ error .= $ this ->printShortUsage (true );
12461246 throw new DeepExitException ($ error , 3 );
12471247 }
12481248
1249- $ this ->generator = self :: $ validGenerators [$ lowerCaseGeneratorName ];
1249+ $ this ->generator = $ this -> validGenerators [$ lowerCaseGeneratorName ];
12501250 self ::$ overriddenDefaults ['generator ' ] = true ;
12511251 } else if (substr ($ arg , 0 , 9 ) === 'encoding= ' ) {
12521252 if (isset (self ::$ overriddenDefaults ['encoding ' ]) === true ) {
0 commit comments