use Consolidation\AnnotatedCommand\Hooks\HookManager;
use Consolidation\AnnotatedCommand\Parser\CommandInfo;
-use Consolidation\OutputFormatters\FormatterManager;
-use Consolidation\OutputFormatters\Options\FormatterOptions;
use Consolidation\AnnotatedCommand\Help\HelpDocumentAlter;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
}
$this->setCommandArguments($commandInfo);
$this->setReturnType($commandInfo->getReturnType());
+ // Hidden commands available since Symfony 3.2
+ // http://symfony.com/doc/current/console/hide_commands.html
+ if (method_exists($this, 'setHidden')) {
+ $this->setHidden($commandInfo->getHidden());
+ }
return $this;
}
*/
protected function checkUsesInputInterface($params)
{
+ /** @var \ReflectionParameter $firstParam */
$firstParam = reset($params);
- return $firstParam instanceof InputInterface;
+ return $firstParam && $firstParam->getClass() && $firstParam->getClass()->implementsInterface(
+ '\\Symfony\\Component\\Console\\Input\\InputInterface'
+ );
}
/**
$index = $this->checkUsesInputInterface($params) ? 1 : 0;
$this->usesOutputInterface =
(count($params) > $index) &&
- ($params[$index] instanceof OutputInterface);
+ $params[$index]->getClass() &&
+ $params[$index]->getClass()->implementsInterface(
+ '\\Symfony\\Component\\Console\\Output\\OutputInterface'
+ )
+ ;
return $this;
}
);
$commandData->setUseIOInterfaces(
- $this->usesOutputInterface,
- $this->usesInputInterface
+ $this->usesInputInterface,
+ $this->usesOutputInterface
);
+ // Allow the commandData to cache the list of options with
+ // special default values ('null' and 'true'), as these will
+ // need special handling. @see CommandData::options().
+ $commandData->cacheSpecialDefaults($this->getDefinition());
+
return $commandData;
}
}