Skip to content

Commit c3a04e8

Browse files
committed
bug fixed for add controller,command
1 parent 7f2ce6f commit c3a04e8

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/AbstractApp.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,15 @@ public function stop($code = 0)
194194
*/
195195
public function controller(string $name, string $controller = null)
196196
{
197-
if (class_exists($name, false)) {
197+
if (!$controller && class_exists($name)) {
198198
/** @var Controller $controller */
199199
$controller = $name;
200200
$name = $controller::getName();
201201
}
202202

203203
if (!$name || !$controller) {
204-
throw new \InvalidArgumentException('Group-command "name" and "controller" not allowed to is empty!');
204+
throw new \InvalidArgumentException('Group-command "name" and "controller" not allowed to is empty! name: '
205+
. $name . ', controller: ' .$controller);
205206
}
206207

207208
$this->validateName($name, true);
@@ -225,7 +226,11 @@ public function controller(string $name, string $controller = null)
225226
public function controllers(array $controllers)
226227
{
227228
foreach ($controllers as $name => $controller) {
228-
$this->controller($name, $controller);
229+
if (is_int($name)) {
230+
$this->controller($controller);
231+
} else {
232+
$this->controller($name, $controller);
233+
}
229234
}
230235
}
231236

@@ -237,7 +242,7 @@ public function controllers(array $controllers)
237242
*/
238243
public function command(string $name, $handler = null)
239244
{
240-
if (class_exists($name)) {
245+
if (!$handler && class_exists($name)) {
241246
/** @var Command $handler */
242247
$handler = $name;
243248
$name = $handler::getName();

0 commit comments

Comments
 (0)