From 8805cfdf8d4ba6776cfd74e290d8d17b0ae1b62d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 30 Sep 2018 05:35:36 +0200 Subject: [PATCH] [Console] simplified code --- src/Symfony/Component/Console/Application.php | 32 +++++++------------ 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index 2e749cfa94..6bad2b5425 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -153,7 +153,17 @@ class Application $renderException($e); - $exitCode = $this->getExitCodeForThrowable($e); + $exitCode = $e->getCode(); + if (is_numeric($exitCode)) { + $exitCode = (int) $exitCode; + if (0 === $exitCode) { + $exitCode = 1; + } + } else { + $exitCode = 1; + } + + return $exitCode; } finally { // if the exception handler changed, keep it // otherwise, unregister $renderException @@ -1212,24 +1222,4 @@ class Application $this->add($command); } } - - /** - * @param \Exception|\Throwable $throwable - * - * @return int - */ - private function getExitCodeForThrowable($throwable) - { - $exitCode = $throwable->getCode(); - if (is_numeric($exitCode)) { - $exitCode = (int) $exitCode; - if (0 === $exitCode) { - $exitCode = 1; - } - } else { - $exitCode = 1; - } - - return $exitCode; - } }