From 492aacb70912285528779c67fda9db2ef0aefb80 Mon Sep 17 00:00:00 2001 From: Fabien Salathe Date: Tue, 18 Oct 2022 15:19:33 +0200 Subject: [PATCH] Add constants for exit return codes Inspired by https://github.com/symfony/symfony/blob/6.2/src/Symfony/Component/Console/Command/Command.php#L37-L40 --- src/Runner.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/Runner.php b/src/Runner.php index e0cbca7160..4f3063d316 100644 --- a/src/Runner.php +++ b/src/Runner.php @@ -23,6 +23,9 @@ class Runner { + const SUCCESS = 0; + const FAILURE = 1; + const INVALID = 2; /** * The config data for the run. @@ -81,7 +84,7 @@ public function runPHPCS() $ruleset->explain(); } - return 0; + return self::SUCCESS; } // Generate documentation for each of the supplied standards. @@ -95,7 +98,7 @@ public function runPHPCS() $generator->generate(); } - return 0; + return self::SUCCESS; } // Other report formats don't really make sense in interactive mode @@ -136,13 +139,13 @@ public function runPHPCS() if ($numErrors === 0) { // No errors found. - return 0; + return self::SUCCESS; } else if ($this->reporter->totalFixable === 0) { // Errors found, but none of them can be fixed by PHPCBF. - return 1; + return self::FAILURE; } else { // Errors found, and some can be fixed by PHPCBF. - return 2; + return self::INVALID; } }//end runPHPCS() @@ -215,20 +218,20 @@ public function runPHPCBF() // Nothing was fixed by PHPCBF. if ($this->reporter->totalFixable === 0) { // Nothing found that could be fixed. - return 0; + return self::SUCCESS; } else { // Something failed to fix. - return 2; + return self::INVALID; } } if ($this->reporter->totalFixable === 0) { // PHPCBF fixed all fixable errors. - return 1; + return self::FAILURE; } // PHPCBF fixed some fixable errors, but others failed to fix. - return 2; + return self::INVALID; }//end runPHPCBF()