Skip to content

Commit 0c18029

Browse files
authored
[9.x] Allow registering instances of commands (#43986)
* allow registering instances of commands * add typehint
1 parent 5de463e commit 0c18029

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Illuminate/Console/Application.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ protected function addToParent(SymfonyCommand $command)
262262
/**
263263
* Add a command, resolving through the application.
264264
*
265-
* @param string $command
265+
* @param \Illuminate\Console\Command|string $command
266266
* @return \Symfony\Component\Console\Command\Command|null
267267
*/
268268
public function resolve($command)
@@ -273,6 +273,10 @@ public function resolve($command)
273273
return null;
274274
}
275275

276+
if ($command instanceof Command) {
277+
return $this->add($command);
278+
}
279+
276280
return $this->add($this->laravel->make($command));
277281
}
278282

0 commit comments

Comments
 (0)