From 445b2e3daddf24df81909cf264e859aa644ed9c5 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Wed, 5 Jun 2013 10:14:54 +0200 Subject: [PATCH 1/2] [Console] fix status code when Exception::getCode returns something like 0.1 --- src/Symfony/Component/Console/Application.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index ad6b85368f..d4ad03a02f 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -113,9 +113,16 @@ class Application } else { $this->renderException($e, $output); } - $statusCode = $e->getCode(); - $statusCode = is_numeric($statusCode) && $statusCode ? (int) $statusCode : 1; + $statusCode = $e->getCode(); + if (is_numeric($statusCode)) { + $statusCode = (int) $statusCode; + if (0 === $statusCode) { + $statusCode = 1; + } + } else { + $statusCode = 1; + } } if ($this->autoExit) { From 6b9180a23ded06648ea8c79251e96ce87dd5c94f Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Wed, 5 Jun 2013 10:18:46 +0200 Subject: [PATCH 2/2] [Console] ensure exit code between 0-254 255 is reserved by PHP and should not be used also put this code inside the codeCoverageIgnore block because it cannot be tested with phpunit --- src/Symfony/Component/Console/Application.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index d4ad03a02f..2c7d3de736 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -126,11 +126,9 @@ class Application } if ($this->autoExit) { - if ($statusCode > 255) { - $statusCode = 255; - } + // ensure exit code is between 0-254 (255 is reserved by PHP and should not be used) // @codeCoverageIgnoreStart - exit($statusCode); + exit(max(0, min(254, $statusCode))); // @codeCoverageIgnoreEnd }