/**
  * 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);
     }
 }