@@ -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.
@@ -1253,18 +1251,20 @@ public function processLongArgument($arg, $pos)
12531251 $ generatorName = substr ($ arg , 10 );
12541252 $ lowerCaseGeneratorName = strtolower ($ generatorName );
12551253
1256- if (isset (self ::$ validGenerators [$ lowerCaseGeneratorName ]) === false ) {
1257- $ validOptions = implode (', ' , array_values (self ::$ validGenerators ));
1258- $ error = sprintf (
1259- 'ERROR: "%s" is not a valid generator. Valid options are: %s. ' .PHP_EOL .PHP_EOL ,
1254+ if (isset ($ this ->validGenerators [$ lowerCaseGeneratorName ]) === false ) {
1255+ $ lastOption = array_pop ($ this ->validGenerators );
1256+ $ validOptions = implode (', ' , $ this ->validGenerators );
1257+ $ validOptions .= ' and ' .$ lastOption ;
1258+ $ error = sprintf (
1259+ 'ERROR: "%s" is not a valid generator. The following generators are supported: %s. ' .PHP_EOL .PHP_EOL ,
12601260 $ generatorName ,
12611261 $ validOptions
12621262 );
1263- $ error .= $ this ->printShortUsage (true );
1263+ $ error .= $ this ->printShortUsage (true );
12641264 throw new DeepExitException ($ error , 3 );
12651265 }
12661266
1267- $ this ->generator = self :: $ validGenerators [$ lowerCaseGeneratorName ];
1267+ $ this ->generator = $ this -> validGenerators [$ lowerCaseGeneratorName ];
12681268 self ::$ overriddenDefaults ['generator ' ] = true ;
12691269 } else if (substr ($ arg , 0 , 9 ) === 'encoding= ' ) {
12701270 if (isset (self ::$ overriddenDefaults ['encoding ' ]) === true ) {
0 commit comments