diff --git a/coder_sniffer/Drupal/Sniffs/ControlStructures/CaseSemicolonSniff.php b/coder_sniffer/Drupal/Sniffs/ControlStructures/CaseSemicolonSniff.php deleted file mode 100644 index 301e13c3..00000000 --- a/coder_sniffer/Drupal/Sniffs/ControlStructures/CaseSemicolonSniff.php +++ /dev/null @@ -1,63 +0,0 @@ - - */ - public function register() - { - return [T_CASE]; - - }//end register() - - - /** - * Processes this test, when one of its tokens is encountered. - * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token in the - * stack passed in $tokens. - * - * @return void - */ - public function process(File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - if (isset($tokens[$stackPtr]['scope_opener']) === true - && $tokens[$tokens[$stackPtr]['scope_opener']]['code'] === T_SEMICOLON - ) { - $error = 'A colon ":" must be used to open a case statement, found ";"'; - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SemicolonNotAllowed'); - if ($fix === true) { - $phpcsFile->fixer->replaceToken($tokens[$stackPtr]['scope_opener'], ':'); - } - } - - }//end process() - - -}//end class diff --git a/coder_sniffer/Drupal/ruleset.xml b/coder_sniffer/Drupal/ruleset.xml index a65099ba..d109843d 100644 --- a/coder_sniffer/Drupal/ruleset.xml +++ b/coder_sniffer/Drupal/ruleset.xml @@ -114,6 +114,11 @@ + + + + + diff --git a/tests/Drupal/ControlStructures/CaseSemicolonUnitTest.php b/tests/Drupal/ControlStructures/CaseSemicolonUnitTest.php deleted file mode 100644 index 79dfe5df..00000000 --- a/tests/Drupal/ControlStructures/CaseSemicolonUnitTest.php +++ /dev/null @@ -1,48 +0,0 @@ - - */ - protected function getErrorList(string $testFile): array - { - return [ - 13 => 1, - 17 => 1, - ]; - - }//end getErrorList() - - - /** - * Returns the lines where warnings should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @param string $testFile The name of the file being tested. - * - * @return array - */ - protected function getWarningList(string $testFile): array - { - return []; - - }//end getWarningList() - - -}//end class diff --git a/tests/Drupal/bad/BadUnitTest.php b/tests/Drupal/bad/BadUnitTest.php index d24dd3a3..2124fbe3 100644 --- a/tests/Drupal/bad/BadUnitTest.php +++ b/tests/Drupal/bad/BadUnitTest.php @@ -367,6 +367,12 @@ protected function getErrorList(string $testFile): array 872 => 1, 876 => 2, ]; + case 'CaseSemicolonUnitTest.inc': + return [ + 1 => 1, + 13 => 1, + 17 => 1, + ]; case 'ClassCreateInstanceUnitTest.inc': return [ 3 => 1, diff --git a/tests/Drupal/ControlStructures/CaseSemicolonUnitTest.inc b/tests/Drupal/bad/CaseSemicolonUnitTest.inc similarity index 100% rename from tests/Drupal/ControlStructures/CaseSemicolonUnitTest.inc rename to tests/Drupal/bad/CaseSemicolonUnitTest.inc diff --git a/tests/Drupal/ControlStructures/CaseSemicolonUnitTest.inc.fixed b/tests/Drupal/bad/CaseSemicolonUnitTest.inc.fixed similarity index 100% rename from tests/Drupal/ControlStructures/CaseSemicolonUnitTest.inc.fixed rename to tests/Drupal/bad/CaseSemicolonUnitTest.inc.fixed