public function runCompletion()
{
if (!$this->context) {
throw new \RuntimeException('A CompletionContext must be set before requesting completion.');
}
$cmdName = $this->getInput()->getFirstArgument();
try {
$this->command = $this->application->find($cmdName);
} catch (\InvalidArgumentException $e) {
// Exception thrown, when multiple or none commands are found.
}
$process = array('completeForOptionValues', 'completeForOptionShortcuts', 'completeForOptionShortcutValues', 'completeForOptions', 'completeForCommandName', 'completeForCommandArguments');
foreach ($process as $methodName) {
$result = $this->{$methodName}();
if (false !== $result) {
// Return the result of the first completion mode that matches
return $this->filterResults((array) $result);
}
}
return array();
}