/** * Test CommandInfo command annotation parsing. */ function testParsing() { $commandInfo = new CommandInfo('\\Consolidation\\TestUtils\\ExampleCommandFile', 'testArithmatic'); $this->assertEquals('test:arithmatic', $commandInfo->getName()); $this->assertEquals('This is the test:arithmatic command', $commandInfo->getDescription()); $this->assertEquals("This command will add one and two. If the --negate flag\nis provided, then the result is negated.", $commandInfo->getHelp()); $this->assertEquals('arithmatic', implode(',', $commandInfo->getAliases())); $this->assertEquals('2 2 --negate=>Add two plus two and then negate.', $this->flattenArray($commandInfo->getExampleUsages())); $this->assertEquals('The first number to add.', $commandInfo->arguments()->getDescription('one')); $this->assertEquals('The other number to add.', $commandInfo->arguments()->getDescription('two')); $this->assertEquals('Whether or not the result should be negated.', $commandInfo->options()->getDescription('negate')); }
/** * 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); }