diff --git a/composer/bin/phpab b/composer/bin/phpab index 0f931c4..df320bd 100755 --- a/composer/bin/phpab +++ b/composer/bin/phpab @@ -59,5 +59,5 @@ foreach ($files as $file) { require __DIR__ . '/../../src/autoload.php'; $factory = new \TheSeer\Autoload\Factory(); -$factory->getCLI()->run($_SERVER); -exit(0); +$rc = $factory->getCLI()->run($_SERVER); +exit($rc); diff --git a/phpab.php b/phpab.php index 2e2bdbd..9b6042c 100755 --- a/phpab.php +++ b/phpab.php @@ -51,5 +51,5 @@ require __DIR__ . '/src/autoload.php'; $factory = new \TheSeer\Autoload\Factory(); -$factory->getCLI()->run($_SERVER); -exit(0); +$rc = $factory->getCLI()->run($_SERVER); +exit($rc); diff --git a/src/CLI.php b/src/CLI.php index 343b2e7..100d86d 100644 --- a/src/CLI.php +++ b/src/CLI.php @@ -71,7 +71,7 @@ public function __construct(Factory $factory) { /** * Main executor method * - * @return void + * @return int exit code */ public function run(array $env) { @@ -99,19 +99,19 @@ public function run(array $env) { $this->showVersion(); } $rc = $this->factory->getApplication()->run(); - exit($rc); + return $rc; } catch (CLIEnvironmentException $e) { $this->showVersion(); fwrite(STDERR, 'Sorry, but your PHP environment is currently not able to run phpab due to'); fwrite(STDERR, "\nthe following issue(s):\n\n" . $e->getMessage() . "\n\n"); fwrite(STDERR, "Please adjust your PHP configuration and try again.\n\n"); - exit(CLI::RC_EXEC_ERROR); + return CLI::RC_EXEC_ERROR; } catch (\ezcConsoleException $e) { $this->showVersion(); echo $e->getMessage() . "\n\n"; $this->showUsage(); - exit(CLI::RC_PARAM_ERROR); + return CLI::RC_PARAM_ERROR; } catch (CollectorException $e) { switch($e->getCode()) { case CollectorException::InFileRedeclarationFound: @@ -126,11 +126,11 @@ public function run(array $env) { } $this->showVersion(); fwrite(STDERR, $message . "\n\n"); - exit(CLI::RC_EXEC_ERROR); + return CLI::RC_EXEC_ERROR; } catch (\Exception $e) { $this->showVersion(); fwrite(STDERR, "\nError while processing request:\n - " . $e->getMessage()."\n"); - exit(CLI::RC_EXEC_ERROR); + return CLI::RC_EXEC_ERROR; } }