diff --git a/src/Config.php b/src/Config.php index 1a3f9c293f..7800463196 100644 --- a/src/Config.php +++ b/src/Config.php @@ -685,10 +685,7 @@ public function processShortArgument($arg, $pos) ob_end_clean(); throw new DeepExitException($output, 0); case 'i' : - ob_start(); - Standards::printInstalledStandards(); - $output = ob_get_contents(); - ob_end_clean(); + $output = Standards::prepareInstalledStandardsForDisplay().PHP_EOL; throw new DeepExitException($output, 0); case 'v' : if ($this->quiet === true) { diff --git a/src/Runner.php b/src/Runner.php index fccd1e112d..351a09afaf 100644 --- a/src/Runner.php +++ b/src/Runner.php @@ -258,11 +258,8 @@ public function init() if (Standards::isInstalledStandard($standard) === false) { // They didn't select a valid coding standard, so help them // out by letting them know which standards are installed. - $error = 'ERROR: the "'.$standard.'" coding standard is not installed. '; - ob_start(); - Standards::printInstalledStandards(); - $error .= ob_get_contents(); - ob_end_clean(); + $error = 'ERROR: the "'.$standard.'" coding standard is not installed.'.PHP_EOL.PHP_EOL; + $error .= Standards::prepareInstalledStandardsForDisplay().PHP_EOL; throw new DeepExitException($error, 3); } } diff --git a/src/Util/Standards.php b/src/Util/Standards.php index ebee5c49b0..d22f233086 100644 --- a/src/Util/Standards.php +++ b/src/Util/Standards.php @@ -312,28 +312,45 @@ public static function getInstalledStandardPath($standard) /** - * Prints out a list of installed coding standards. + * Prepares a list of installed coding standards for display. * - * @return void + * @return string */ - public static function printInstalledStandards() + public static function prepareInstalledStandardsForDisplay() { $installedStandards = self::getInstalledStandards(); $numStandards = count($installedStandards); + $output = ''; if ($numStandards === 0) { - echo 'No coding standards are installed.'.PHP_EOL; + $output .= 'No coding standards are installed.'; } else { $lastStandard = array_pop($installedStandards); if ($numStandards === 1) { - echo "The only coding standard installed is $lastStandard".PHP_EOL; + $output .= "The only coding standard installed is $lastStandard"; } else { $standardList = implode(', ', $installedStandards); $standardList .= ' and '.$lastStandard; - echo 'The installed coding standards are '.$standardList.PHP_EOL; + $output .= 'The installed coding standards are '.$standardList; } } + return $output; + + }//end prepareInstalledStandardsForDisplay() + + + /** + * Prints out a list of installed coding standards. + * + * @deprecated 4.0.0 Use `echo Standards::prepareInstalledStandardsForDisplay()` instead. + * + * @return void + */ + public static function printInstalledStandards() + { + echo self::prepareInstalledStandardsForDisplay(), PHP_EOL; + }//end printInstalledStandards()