Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 2 additions & 5 deletions src/Runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
29 changes: 23 additions & 6 deletions src/Util/Standards.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down