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");
     }
 }
 /**
  * Register a command hook given the CommandInfo for a method.
  *
  * The hook format is:
  *
  *   @hook type name type
  *
  * For example, the pre-validate hook for the core:init command is:
  *
  *   @hook pre-validate core:init
  *
  * If no command name is provided, then this hook will affect every
  * command that is defined in the same file.
  *
  * If no hook is provided, then we will presume that ALTER_RESULT
  * is intended.
  *
  * @param CommandInfo $commandInfo Information about the command hook method.
  * @param object $commandFileInstance An instance of the CommandFile class.
  */
 public function registerCommandHook(CommandInfo $commandInfo, $commandFileInstance)
 {
     // Ignore if the command info has no @hook
     if (!$commandInfo->hasAnnotation('hook')) {
         return;
     }
     $hookData = $commandInfo->getAnnotation('hook');
     $hook = $this->getNthWord($hookData, 0, HookManager::ALTER_RESULT);
     $commandName = $this->getNthWord($hookData, 1);
     // Register the hook
     $callback = [$commandFileInstance, $commandInfo->getMethodName()];
     $this->commandProcessor()->hookManager()->add($callback, $hook, $commandName);
     // If the hook has options, then also register the commandInfo
     // with the hook manager, so that we can add options and such to
     // the commands they hook.
     if (!$commandInfo->options()->isEmpty()) {
         $this->commandProcessor()->hookManager()->recordHookOptions($commandInfo, $commandName);
     }
 }