function GlobalCommand::run
Throws
\Symfony\Component\Console\Exception\ExceptionInterface
Overrides Command::run
File
-
vendor/
composer/ composer/ src/ Composer/ Command/ GlobalCommand.php, line 93
Class
- GlobalCommand
- @author Jordi Boggiano <j.boggiano@seld.be>
Namespace
Composer\CommandCode
public function run(InputInterface $input, OutputInterface $output) : int {
// TODO remove for Symfony 6+ as it is then in the interface
if (!method_exists($input, '__toString')) {
// @phpstan-ignore-line
throw new \LogicException('Expected an Input instance that is stringable, got ' . get_class($input));
}
// extract real command name
$tokens = Preg::split('{\\s+}', $input->__toString());
$args = [];
foreach ($tokens as $token) {
if ($token && $token[0] !== '-') {
$args[] = $token;
if (count($args) >= 2) {
break;
}
}
}
// show help for this command if no command was found
if (count($args) < 2) {
return parent::run($input, $output);
}
$input = $this->prepareSubcommandInput($input);
return $this->getApplication()
->run($input, $output);
}