diff --git a/src/Console/MacrosCommand.php b/src/Console/MacrosCommand.php index 216546c..d81e61f 100644 --- a/src/Console/MacrosCommand.php +++ b/src/Console/MacrosCommand.php @@ -7,7 +7,7 @@ class MacrosCommand extends Command { /** @var string The name and signature of the console command */ - protected $signature = 'ide-helper:macros'; + protected $signature = 'ide-helper:macros {--filename=}'; /** @var string The console command description */ protected $description = 'Generate an IDE helper file for Laravel macros'; @@ -60,7 +60,7 @@ public function handle() { $classes = array_merge($this->classes, config('ide-macros.classes', [])); - $fileName = config('ide-macros.filename'); + $fileName = $this->option('filename') ?: config('ide-macros.filename'); $this->file = fopen(base_path($fileName), 'w'); $this->writeLine("generateNamespace($reflection->getNamespaceName(), function () use ($macros, $reflection) { $this->generateClass($reflection->getShortName(), function () use ($macros) { foreach ($macros as $name => $macro) { - $function = new \ReflectionFunction($macro); + if(is_array($macro)) { + list($class, $method) = $macro; + $function = new \ReflectionMethod(is_object($class) ? get_class($class) : $class, $method); + } else { + $function = new \ReflectionFunction($macro); + } + if ($comment = $function->getDocComment()) { $this->writeLine($comment, $this->indent);