public function run($args = null) { global $argv; if ($args === null) { $args = $argv; $args[0] = $this->name; } if ($this->root->run($args)) { return; } foreach ($this->contexts as $context) { if ($context['instance']->run($args)) { return; } } $this->dispatcher->dispatch(self::EVENT_INVALID_USAGE, new InvalidUsageEvent($args, $this->root->getOptionDefinitions())); }