/** * Returns the names of the global options for this command. * @return array the names of the global options for this command. */ public function globalOptions() { return array_merge(parent::globalOptions(), ['migrationPath', 'migrationTable', 'db', 'templateFile', 'interactive', 'color']); }
/** * Returns the help information about the options available for a console controller. * @param Controller $controller the console controller * @return array the help information about the options */ protected function getOptionHelps($controller) { $optionNames = $controller->globalOptions(); if (empty($optionNames)) { return []; } $class = new \ReflectionClass($controller); $options = []; foreach ($class->getProperties() as $property) { $name = $property->getName(); if (!in_array($name, $optionNames, true)) { continue; } $defaultValue = $property->getValue($controller); $tags = $this->parseComment($property->getDocComment()); if (isset($tags['var']) || isset($tags['property'])) { $doc = isset($tags['var']) ? $tags['var'] : $tags['property']; if (is_array($doc)) { $doc = reset($doc); } if (preg_match('/^([^\\s]+)(.*)/s', $doc, $matches)) { $type = $matches[1]; $comment = $matches[2]; } else { $type = null; $comment = $doc; } $options[$name] = $this->formatOptionHelp($this->ansiFormat('--' . $name, Console::FG_RED), false, $type, $defaultValue, $comment); } else { $options[$name] = $this->formatOptionHelp($this->ansiFormat('--' . $name, Console::FG_RED), false, null, $defaultValue, ''); } } ksort($options); return $options; }
/** * Returns the names of the global options for this command. * @return array the names of the global options for this command. */ public function globalOptions() { return array_merge(parent::globalOptions(), ['db', 'fixturePath']); }