@@ -118,7 +118,7 @@ public function __construct(array $config = [], Input $input = null, Output $out
118118 /**
119119 * @throws \InvalidArgumentException
120120 */
121- protected function init ()
121+ protected function init (): void
122122 {
123123 $ this ->stats = [
124124 'startTime ' => \microtime (1 ),
@@ -145,7 +145,7 @@ public static function getGlobalOptions(): array
145145 /**
146146 * @param array $options
147147 */
148- public function addGlobalOptions (array $ options )
148+ public function addGlobalOptions (array $ options ): void
149149 {
150150 if ($ options ) {
151151 self ::$ globalOptions = \array_merge (self ::$ globalOptions , $ options );
@@ -156,7 +156,7 @@ public function addGlobalOptions(array $options)
156156 * app run
157157 **********************************************************/
158158
159- protected function prepareRun ()
159+ protected function prepareRun (): void
160160 {
161161 if ($ this ->input ->getSameOpt (['no-color ' ])) {
162162 Style::setNoColor ();
@@ -166,7 +166,7 @@ protected function prepareRun()
166166 // new AutoCompletion(array_merge($this->getCommandNames(), $this->getControllerNames()));
167167 }
168168
169- protected function beforeRun ()
169+ protected function beforeRun (): void
170170 {
171171 }
172172
@@ -220,7 +220,7 @@ public function run(bool $exit = true)
220220 */
221221 abstract protected function dispatch (string $ command );
222222
223- protected function afterRun ()
223+ protected function afterRun (): void
224224 {
225225 }
226226
@@ -267,7 +267,7 @@ public function subRun(string $command, InputInterface $input, OutputInterface $
267267 /**
268268 * runtime env check
269269 */
270- protected function runtimeCheck ()
270+ protected function runtimeCheck (): void
271271 {
272272 // check env
273273 if (!\in_array (\PHP_SAPI , ['cli ' , 'phpdbg ' , 'cli-server ' ], true )) {
@@ -282,7 +282,7 @@ protected function runtimeCheck()
282282 * register error handle
283283 * @throws \InvalidArgumentException
284284 */
285- protected function registerErrorHandle ()
285+ protected function registerErrorHandle (): void
286286 {
287287 \set_error_handler ([$ this , 'handleError ' ]);
288288 \set_exception_handler ([$ this , 'handleException ' ]);
@@ -301,7 +301,7 @@ protected function registerErrorHandle()
301301 * @param int $line
302302 * @throws \InvalidArgumentException
303303 */
304- public function handleError (int $ num , string $ str , string $ file , int $ line )
304+ public function handleError (int $ num , string $ str , string $ file , int $ line ): void
305305 {
306306 $ this ->handleException (new \ErrorException ($ str , 0 , $ num , $ file , $ line ));
307307 $ this ->stop (-1 );
@@ -312,7 +312,7 @@ public function handleError(int $num, string $str, string $file, int $line)
312312 * @param \Throwable $e
313313 * @throws \InvalidArgumentException
314314 */
315- public function handleException ($ e )
315+ public function handleException ($ e ): void
316316 {
317317 // you can log error on sub class ...
318318
@@ -365,7 +365,7 @@ protected function filterSpecialCommand(string $command): bool
365365 * @param bool $isGroup
366366 * @throws \InvalidArgumentException
367367 */
368- protected function validateName (string $ name , bool $ isGroup = false )
368+ protected function validateName (string $ name , bool $ isGroup = false ): void
369369 {
370370 $ pattern = $ isGroup ? '/^[a-z][\w-]+$/ ' : '/^[a-z][\w-]*:?([a-z][\w-]+)?$/ ' ;
371371
@@ -413,11 +413,7 @@ protected function getRealCommandName(string $name): string
413413 */
414414 public function findCommand (string $ name )
415415 {
416- if (isset ($ this ->commands [$ name ])) {
417- return $ this ->commands [$ name ];
418- }
419-
420- return $ this ->controllers [$ name ] ?? null ;
416+ return $ this ->commands [$ name ] ?? $ this ->controllers [$ name ] ?? null ;
421417 }
422418
423419 /**********************************************************
@@ -444,7 +440,7 @@ public function getCommandNames(): array
444440 * @param array $controllers
445441 * @throws \InvalidArgumentException
446442 */
447- public function setControllers (array $ controllers )
443+ public function setControllers (array $ controllers ): void
448444 {
449445 foreach ($ controllers as $ name => $ controller ) {
450446 if (\is_int ($ name )) {
@@ -476,7 +472,7 @@ public function isController(string $name): bool
476472 * @param array $commands
477473 * @throws \InvalidArgumentException
478474 */
479- public function setCommands (array $ commands )
475+ public function setCommands (array $ commands ): void
480476 {
481477 foreach ($ commands as $ name => $ handler ) {
482478 if (\is_int ($ name )) {
@@ -507,7 +503,7 @@ public function isCommand(string $name): bool
507503 /**
508504 * @return string|null
509505 */
510- public function getLogoText ()
506+ public function getLogoText (): ? string
511507 {
512508 return $ this ->config ['logoText ' ] ?? null ;
513509 }
@@ -516,7 +512,7 @@ public function getLogoText()
516512 * @param string $logoTxt
517513 * @param string|null $style
518514 */
519- public function setLogo (string $ logoTxt , string $ style = null )
515+ public function setLogo (string $ logoTxt , string $ style = null ): void
520516 {
521517 $ this ->config ['logoText ' ] = $ logoTxt ;
522518
@@ -528,15 +524,15 @@ public function setLogo(string $logoTxt, string $style = null)
528524 /**
529525 * @return string|null
530526 */
531- public function getLogoStyle ()
527+ public function getLogoStyle (): ? string
532528 {
533529 return $ this ->config ['logoStyle ' ] ?? 'info ' ;
534530 }
535531
536532 /**
537533 * @param string $style
538534 */
539- public function setLogoStyle (string $ style )
535+ public function setLogoStyle (string $ style ): void
540536 {
541537 $ this ->config ['logoStyle ' ] = $ style ;
542538 }
@@ -585,7 +581,7 @@ public function getVersion(): string
585581 /**
586582 * @param array $config
587583 */
588- public function setConfig (array $ config )
584+ public function setConfig (array $ config ): void
589585 {
590586 if ($ config ) {
591587 $ this ->config = \array_merge ($ this ->config , $ config );
@@ -645,7 +641,7 @@ public function getCommandAliases(string $name = null): array
645641 /**
646642 * @param array $commandAliases
647643 */
648- public function setCommandAliases (array $ commandAliases )
644+ public function setCommandAliases (array $ commandAliases ): void
649645 {
650646 $ this ->commandAliases = $ commandAliases ;
651647 }
@@ -662,7 +658,7 @@ public function getCommandsMeta(): array
662658 * @param string $command
663659 * @param array $meta
664660 */
665- public function setCommandMeta (string $ command , array $ meta )
661+ public function setCommandMeta (string $ command , array $ meta ): void
666662 {
667663 if (isset ($ this ->commandsMeta [$ command ])) {
668664 $ this ->commandsMeta [$ command ] = \array_merge ($ this ->commandsMeta [$ command ], $ meta );
@@ -685,7 +681,7 @@ public function getCommandMeta(string $command): array
685681 * @param string $key
686682 * @param $value
687683 */
688- public function setCommandMetaValue (string $ command , string $ key , $ value )
684+ public function setCommandMetaValue (string $ command , string $ key , $ value ): void
689685 {
690686 if ($ value !== null ) {
691687 $ this ->commandsMeta [$ command ][$ key ] = $ value ;
0 commit comments