diff --git a/Util/Helper.php b/Util/Helper.php index 9a0ca0e..544a437 100644 --- a/Util/Helper.php +++ b/Util/Helper.php @@ -5,6 +5,7 @@ use Doctrine\Common\Annotations\AnnotationReader; use Padam87\CronBundle\Annotation\Job; use Symfony\Component\Console\Application; +use Symfony\Component\Console\Command\LazyCommand; use Symfony\Component\Console\Input\InputInterface; class Helper @@ -23,7 +24,11 @@ public function createTab(InputInterface $input, ?array $config = null): Tab $tab = new Tab(); foreach($this->application->all() as $command) { - $annotations = $this->annotationReader->getClassAnnotations(new \ReflectionClass($command)); + $commandInstance = $command instanceof LazyCommand + ? $command->getCommand() + : $command; + + $annotations = $this->annotationReader->getClassAnnotations(new \ReflectionClass($commandInstance)); foreach ($annotations as $annotation) { if ($annotation instanceof Job) { @@ -37,7 +42,7 @@ public function createTab(InputInterface $input, ?array $config = null): Tab '%s %s %s', $config['php_binary'], realpath($_SERVER['argv'][0]), - $annotation->commandLine === null ? $command->getName() : $annotation->commandLine + $annotation->commandLine === null ? $commandInstance->getName() : $annotation->commandLine ); if ($config['log_dir'] !== null && $annotation->logFile !== null) {