function Application::run
Same name in this branch
- 11.1.x vendor/phpunit/phpunit/src/TextUI/Application.php \PHPUnit\TextUI\Application::run()
- 11.1.x vendor/composer/composer/src/Composer/Console/Application.php \Composer\Console\Application::run()
Runs the current application.
Return value
int 0 if everything went fine, or an error code
Throws
\Exception When running fails. Bypass this when {@link setCatchExceptions()}.
2 calls to Application::run()
- Application::run in vendor/
composer/ composer/ src/ Composer/ Console/ Application.php - Runs the current application.
- Application::run in vendor/
composer/ composer/ src/ Composer/ Console/ Application.php - Runs the current application.
1 method overrides Application::run()
- Application::run in vendor/
composer/ composer/ src/ Composer/ Console/ Application.php - Runs the current application.
File
-
vendor/
symfony/ console/ Application.php, line 164
Class
- Application
- An Application is the container for a collection of commands.
Namespace
Symfony\Component\ConsoleCode
public function run(?InputInterface $input = null, ?OutputInterface $output = null) : int {
if (\function_exists('putenv')) {
@putenv('LINES=' . $this->terminal
->getHeight());
@putenv('COLUMNS=' . $this->terminal
->getWidth());
}
$input ??= new ArgvInput();
$output ??= new ConsoleOutput();
$renderException = function (\Throwable $e) use ($output) {
if ($output instanceof ConsoleOutputInterface) {
$this->renderThrowable($e, $output->getErrorOutput());
}
else {
$this->renderThrowable($e, $output);
}
};
if ($phpHandler = set_exception_handler($renderException)) {
restore_exception_handler();
if (!\is_array($phpHandler) || !$phpHandler[0] instanceof ErrorHandler) {
$errorHandler = true;
}
elseif ($errorHandler = $phpHandler[0]->setExceptionHandler($renderException)) {
$phpHandler[0]->setExceptionHandler($errorHandler);
}
}
try {
$this->configureIO($input, $output);
$exitCode = $this->doRun($input, $output);
} catch (\Throwable $e) {
if ($e instanceof \Exception && !$this->catchExceptions) {
throw $e;
}
if (!$e instanceof \Exception && !$this->catchErrors) {
throw $e;
}
$renderException($e);
$exitCode = $e->getCode();
if (is_numeric($exitCode)) {
$exitCode = (int) $exitCode;
if ($exitCode <= 0) {
$exitCode = 1;
}
}
else {
$exitCode = 1;
}
} finally {
// if the exception handler changed, keep it
// otherwise, unregister $renderException
if (!$phpHandler) {
if (set_exception_handler($renderException) === $renderException) {
restore_exception_handler();
}
restore_exception_handler();
}
elseif (!$errorHandler) {
$finalHandler = $phpHandler[0]->setExceptionHandler(null);
if ($finalHandler !== $renderException) {
$phpHandler[0]->setExceptionHandler($finalHandler);
}
}
}
if ($this->autoExit) {
if ($exitCode > 255) {
$exitCode = 255;
}
exit($exitCode);
}
return $exitCode;
}