@@ -184,10 +184,10 @@ public function option_d(string $k, mixed $v): array
184184 public function option_docbook (string $ k , mixed $ v ): array
185185 {
186186 if (is_array ($ v )) {
187- trigger_error ( " Can only parse one file at a time " , E_USER_ERROR );
187+ throw new \ Error ( ' Can only parse one file at a time ' );
188188 }
189189 if (!file_exists ($ v ) || is_dir ($ v ) || !is_readable ($ v )) {
190- trigger_error (sprintf ("'%s' is not a readable docbook file " , $ v ), E_USER_ERROR );
190+ throw new \ Error (sprintf ("'%s' is not a readable docbook file " , $ v ));
191191 }
192192 return [
193193 'xmlRoot ' => dirname ($ v ),
@@ -209,19 +209,19 @@ public function option_o(string $k, mixed $v): array
209209 public function option_output (string $ k , mixed $ v ): array
210210 {
211211 if (is_array ($ v )) {
212- trigger_error ( " Only a single output location can be supplied " , E_USER_ERROR );
212+ throw new \ Error ( ' Only a single output location can be supplied ' );
213213 }
214214 if (!file_exists ($ v )) {
215215 $ this ->outputHandler ->v ("Creating output directory.. " , VERBOSE_MESSAGES );
216216 if (!mkdir ($ v , 0777 , true )) {
217- trigger_error (vsprintf ("Can't create output directory : %s " , [$ v ]), E_USER_ERROR );
217+ throw new \ Error (vsprintf ("Can't create output directory : %s " , [$ v ]));
218218 }
219219 $ this ->outputHandler ->v ("Output directory created " , VERBOSE_MESSAGES );
220220 } elseif (!is_dir ($ v )) {
221- trigger_error ( " Output directory is a file? " , E_USER_ERROR );
221+ throw new \ Error ( ' Output directory is a file? ' );
222222 }
223223 if (!is_dir ($ v ) || !is_readable ($ v )) {
224- trigger_error (sprintf ("'%s' is not a valid directory " , $ v ), E_USER_ERROR );
224+ throw new \ Error (sprintf ("'%s' is not a valid directory " , $ v ));
225225 }
226226 $ v = (substr ($ v , strlen ($ v ) - strlen (DIRECTORY_SEPARATOR )) === DIRECTORY_SEPARATOR ) ? $ v : ($ v . DIRECTORY_SEPARATOR );
227227
@@ -234,7 +234,7 @@ public function option_output(string $k, mixed $v): array
234234 public function option_outputfilename (string $ k , mixed $ v ): array
235235 {
236236 if (is_array ($ v )) {
237- trigger_error ( " Only a single output location can be supplied " , E_USER_ERROR );
237+ throw new \ Error ( ' Only a single output location can be supplied ' );
238238 }
239239 $ file = basename ($ v );
240240
@@ -281,7 +281,7 @@ public function option_package(string $k, mixed $v): array
281281 foreach ((array )$ v as $ package ) {
282282 if (!in_array ($ package , $ this ->config ->getSupportedPackages ())) {
283283 $ supported = implode (', ' , $ this ->config ->getSupportedPackages ());
284- trigger_error ("Invalid Package (Tried: ' $ package' Supported: ' $ supported') " , E_USER_ERROR );
284+ throw new \ Error ("Invalid Package (Tried: ' $ package' Supported: ' $ supported') " );
285285 }
286286 }
287287 return ['package ' => (array ) $ v ];
@@ -341,13 +341,13 @@ public function option_skip(string $k, mixed $v): array
341341 public function option_saveconfig (string $ k , mixed $ v ): array
342342 {
343343 if (is_array ($ v )) {
344- trigger_error (sprintf (" You cannot pass %s more than once " , $ k ), E_USER_ERROR );
344+ throw new \ Error (sprintf (' You cannot pass %s more than once ' , $ k ));
345345 }
346346
347347 $ val = is_bool ($ v ) ? true : self ::boolval ($ v );
348348
349349 if (!is_bool ($ val )) {
350- trigger_error ( " yes/no || on/off || true/false || 1/0 expected " , E_USER_ERROR );
350+ throw new \ Error ( ' yes/no || on/off || true/false || 1/0 expected ' );
351351 }
352352
353353 return ['saveConfig ' => $ val ];
@@ -381,7 +381,7 @@ public function option_verbose(string $k, mixed $v): array
381381 $ verbose = max ($ verbose , 1 );
382382 $ verbose <<= 1 ;
383383 } else {
384- trigger_error ("Unknown option passed to -- $ k, ' $ const' " , E_USER_ERROR );
384+ throw new \ Error ("Unknown option passed to -- $ k, ' $ const' " );
385385 }
386386 }
387387 }
@@ -438,11 +438,11 @@ public function option_c(string $k, mixed $v): array
438438 public function option_color (string $ k , mixed $ v ): array
439439 {
440440 if (is_array ($ v )) {
441- trigger_error (sprintf (" You cannot pass %s more than once " , $ k ), E_USER_ERROR );
441+ throw new \ Error (sprintf (' You cannot pass %s more than once ' , $ k ));
442442 }
443443 $ val = self ::boolval ($ v );
444444 if (!is_bool ($ val )) {
445- trigger_error ( " yes/no || on/off || true/false || 1/0 expected " , E_USER_ERROR );
445+ throw new \ Error ( ' yes/no || on/off || true/false || 1/0 expected ' );
446446 }
447447 return ['colorOutput ' => $ val ];
448448 }
0 commit comments