diff --git a/src/Illuminate/Console/Scheduling/Schedule.php b/src/Illuminate/Console/Scheduling/Schedule.php index 658ab4b20f76..24742d1d3e19 100644 --- a/src/Illuminate/Console/Scheduling/Schedule.php +++ b/src/Illuminate/Console/Scheduling/Schedule.php @@ -38,7 +38,7 @@ public function call($callback, array $parameters = []) public function command($command, array $parameters = []) { if (class_exists($command)) { - $command = (new $command)->getName(); + $command = app($command)->getName(); } $binary = ProcessUtils::escapeArgument((new PhpExecutableFinder)->find(false)); diff --git a/tests/Console/ConsoleEventSchedulerTest.php b/tests/Console/ConsoleEventSchedulerTest.php index 0248c3f0a6d2..435fb811310f 100644 --- a/tests/Console/ConsoleEventSchedulerTest.php +++ b/tests/Console/ConsoleEventSchedulerTest.php @@ -61,7 +61,26 @@ public function testCreateNewArtisanCommandUsingCommandClass() } } +class FooClassStub +{ + protected $schedule; + + public function __construct(Schedule $schedule) + { + $this->schedule = $schedule; + } +} + class ConsoleCommandStub extends Illuminate\Console\Command { protected $signature = 'foo:bar'; + + protected $foo; + + public function __construct(FooClassStub $foo) + { + parent::__construct(); + + $this->foo = $foo; + } }