From e516c4f01b3ee312666b5adf7d2b3e6d222a2e76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20R=C3=BCegg?= Date: Mon, 18 Sep 2023 20:20:16 +0200 Subject: [PATCH] Return exit code from CLI::run(), rather than exiting --- src/CLI.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/CLI.php b/src/CLI.php index 100d86d..f16688f 100644 --- a/src/CLI.php +++ b/src/CLI.php @@ -73,7 +73,8 @@ public function __construct(Factory $factory) { * * @return int exit code */ - public function run(array $env) { + public function run(array $env): int + { try { @@ -85,12 +86,12 @@ public function run(array $env) { if ($input->getOption('help')->value === TRUE) { $this->showVersion(); $this->showUsage(); - exit(CLI::RC_OK); + return CLI::RC_OK; } if ($input->getOption('version')->value === TRUE ) { $this->showVersion(); - exit(CLI::RC_OK); + return CLI::RC_OK; } $config = $this->configure($env, $input); @@ -98,8 +99,8 @@ public function run(array $env) { if (!$config->isQuietMode()) { $this->showVersion(); } - $rc = $this->factory->getApplication()->run(); - return $rc; + + return $this->factory->getApplication()->run(); } catch (CLIEnvironmentException $e) { $this->showVersion();