diff --git a/src/Config.php b/src/Config.php index 4a7d99c5de..2dc808601d 100644 --- a/src/Config.php +++ b/src/Config.php @@ -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); } @@ -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); } @@ -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. *