77 * @license https://github.com/inhere/php-console/blob/master/LICENSE
88 */
99
10- namespace Inhere \Console ;
10+ namespace Inhere \Console \ Component ;
1111
1212use Closure ;
13+ use Inhere \Console \Command ;
1314use Inhere \Console \Contract \CommandInterface ;
1415use Inhere \Console \Contract \ControllerInterface ;
1516use Inhere \Console \Contract \RouterInterface ;
17+ use Inhere \Console \Controller ;
1618use Inhere \Console \Util \Helper ;
1719use InvalidArgumentException ;
1820use Toolkit \Stdlib \Obj \Traits \NameAliasTrait ;
@@ -86,15 +88,15 @@ class Router implements RouterInterface
8688 *
8789 * @param string $name The controller name
8890 * @param string|ControllerInterface|null $class The controller class
89- * @param array $options
91+ * @param array{aliases: array, desc: string} $config config for group.
9092 * array:
9193 * - aliases The command aliases
92- * - description The description message
94+ * - desc The description message
9395 *
94- * @return Router
96+ * @return static
9597 * @throws InvalidArgumentException
9698 */
97- public function addGroup (string $ name , ControllerInterface |string $ class = null , array $ options = []): RouterInterface
99+ public function addGroup (string $ name , ControllerInterface |string $ class = null , array $ config = []): static
98100 {
99101 /**
100102 * @var Controller $class name is an controller class
@@ -141,7 +143,7 @@ public function addGroup(string $name, ControllerInterface|string $class = null,
141143 ];
142144
143145 // has alias option
144- if (isset ( $ options ['aliases ' ]) ) {
146+ if ($ options ['aliases ' ]) {
145147 $ this ->setAlias ($ name , $ options ['aliases ' ], true );
146148 }
147149
@@ -151,17 +153,13 @@ public function addGroup(string $name, ControllerInterface|string $class = null,
151153 /**
152154 * Register a app independent console command
153155 *
154- * @param string|CommandInterface $name
156+ * @param string|class-string $name
155157 * @param string|Closure|CommandInterface|null $handler
156- * @param array $options
157- * array:
158- * - aliases The command aliases
159- * - description The description message
158+ * @param array{aliases: array, desc: string} $config
160159 *
161- * @return Router|RouterInterface
162- * @throws InvalidArgumentException
160+ * @return static
163161 */
164- public function addCommand (string $ name , string |Closure |CommandInterface $ handler = null , array $ options = []): RouterInterface
162+ public function addCommand (string $ name , string |Closure |CommandInterface $ handler = null , array $ config = []): static
165163 {
166164 if (!$ handler && class_exists ($ name )) {
167165 $ handler = $ name ;
@@ -217,7 +215,7 @@ public function addCommand(string $name, string|Closure|CommandInterface $handle
217215 ];
218216
219217 // has alias option
220- if (isset ( $ options ['aliases ' ]) ) {
218+ if ($ options ['aliases ' ]) {
221219 $ this ->setAlias ($ name , $ options ['aliases ' ], true );
222220 }
223221
0 commit comments