diff --git a/src/Application.php b/src/Application.php index 14e7cf7..f58de0a 100644 --- a/src/Application.php +++ b/src/Application.php @@ -130,6 +130,10 @@ public function command(string $name, $handler = null, $option = null) return $this; } + // allow define aliases in Command class by Command::aliases() + if ($aliases = $handler::aliases()) { + $option['aliases'] = isset($option['aliases']) ? \array_merge($option['aliases'], $aliases) : $aliases; + } } elseif (!\is_object($handler) || !\method_exists($handler, '__invoke')) { Helper::throwInvalidArgument( 'The console command handler must is an subclass of %s OR a Closure OR a object have method __invoke()', @@ -137,11 +141,6 @@ public function command(string $name, $handler = null, $option = null) ); } - // allow define aliases in Command class by Command::aliases() - if ($aliases = $handler::aliases()) { - $option['aliases'] = isset($option['aliases']) ? \array_merge($option['aliases'], $aliases) : $aliases; - } - // is an class name string $this->commands[$name] = $handler;