function testValidFormats() { $formatter = new FormatterManager(); $formatter->addDefaultFormatters(); $formatter->addDefaultSimplifiers(); $commandInfo = new CommandInfo('\\Consolidation\\TestUtils\\alpha\\AlphaCommandFile', 'exampleTable'); $this->assertEquals('example:table', $commandInfo->getName()); $this->assertEquals('\\Consolidation\\OutputFormatters\\StructuredData\\RowsOfFields', $commandInfo->getReturnType()); }
/** * Store the data from a @param annotation in our argument descriptions. */ protected function processParamTag($tag) { $variableName = $tag->getVariableName(); $variableName = str_replace('$', '', $variableName); $description = static::removeLineBreaks((string) $tag->getDescription()); if ($variableName == $this->commandInfo->optionParamName()) { return; } $this->commandInfo->arguments()->add($variableName, $description); }
public function __construct($name = null) { $commandInfo = false; // If this is a subclass of AnnotatedCommand, check to see // if the 'execute' method is annotated. We could do this // unconditionally; it is a performance optimization to skip // checking the annotations if $this is an instance of // AnnotatedCommand. Alternately, we break out a new subclass. // The command factory instantiates the subclass. if (get_class($this) != 'Consolidation\\AnnotatedCommand\\AnnotatedCommand') { $commandInfo = new CommandInfo($this, 'execute'); if (!isset($name)) { $name = $commandInfo->getName(); } } parent::__construct($name); if ($commandInfo && $commandInfo->hasAnnotation('command')) { $this->setCommandInfo($commandInfo); $this->setCommandOptions($commandInfo); } }
public function alterCommandInfo(CommandInfo $commandInfo, $commandFileInstance) { if ($commandInfo->hasAnnotation('arbitrary')) { $commandInfo->addAnnotation('dynamic', "This annotation was dynamically added by ExampleCommandInfoAlterer"); } }
/** * Get the options that are implied by annotations, e.g. @fields implies * that there should be a --fields and a --format option. * * @return InputOption[] */ public function automaticOptions(CommandInfo $commandInfo) { $automaticOptions = []; $formatManager = $this->commandProcessor()->formatterManager(); if ($formatManager) { $annotationData = $commandInfo->getAnnotations()->getArrayCopy(); $formatterOptions = new FormatterOptions($annotationData); $dataType = $commandInfo->getReturnType(); $automaticOptions = $formatManager->automaticOptions($formatterOptions, $dataType); } return $automaticOptions; }
function testReturnValue() { $commandInfo = new CommandInfo('\\Consolidation\\TestUtils\\alpha\\AlphaCommandFile', 'exampleTable'); $this->assertEquals('example:table', $commandInfo->getName()); $this->assertEquals('\\Consolidation\\OutputFormatters\\StructuredData\\RowsOfFields', $commandInfo->getReturnType()); }