Skip to content
Closed
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
19 changes: 19 additions & 0 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,7 @@ public function processLongArgument($arg, $pos)
foreach ($sniffs as $sniff) {
if (substr_count($sniff, '.') !== 2) {
$error = 'ERROR: The specified sniff code "'.$sniff.'" is invalid'.PHP_EOL.PHP_EOL;
$error .= 'Perhaps try following sniff code: '.$this->getSuggestedSniffCode($sniff).PHP_EOL.PHP_EOL;
$error .= $this->printShortUsage(true);
throw new DeepExitException($error, 3);
}
Expand All @@ -850,6 +851,7 @@ public function processLongArgument($arg, $pos)
foreach ($sniffs as $sniff) {
if (substr_count($sniff, '.') !== 2) {
$error = 'ERROR: The specified sniff code "'.$sniff.'" is invalid'.PHP_EOL.PHP_EOL;
$error .= 'Perhaps try following sniff code: '.$this->getSuggestedSniffCode($sniff).PHP_EOL.PHP_EOL;
$error .= $this->printShortUsage(true);
throw new DeepExitException($error, 3);
}
Expand Down Expand Up @@ -1354,6 +1356,23 @@ public function printShortUsage($return=false)
}//end printShortUsage()


/**
* Suggest a sniff code by only combining first three elements.
*
* @param string $sniff Sniff code
*
* @return string
*/
public function getSuggestedSniffCode($sniff)
{
$elements = explode('.', $sniff);
$elements = array_slice($elements, 0, 3);

return implode('.', $elements);

}//end getSuggestedSniffCode()


/**
* Prints out the usage information for PHPCS.
*
Expand Down