diff --git a/src/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php b/src/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php index 8d5957c89a..5176c0af40 100644 --- a/src/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php +++ b/src/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php @@ -11,6 +11,7 @@ use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Util\Tokens; class EmptyStyleDefinitionSniff implements Sniff { @@ -47,8 +48,11 @@ public function register() public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - $next = $phpcsFile->findNext([T_WHITESPACE, T_COLON], ($stackPtr + 1), null, true); + $ignore = Tokens::$emptyTokens; + $ignore[] = T_COLON; + + $next = $phpcsFile->findNext($ignore, ($stackPtr + 1), null, true); if ($next === false || $tokens[$next]['code'] === T_SEMICOLON || $tokens[$next]['line'] !== $tokens[$stackPtr]['line']) { $error = 'Style definition is empty'; $phpcsFile->addError($error, $stackPtr, 'Found'); diff --git a/src/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.css b/src/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.css index 88699a85e6..24910b714c 100644 --- a/src/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.css +++ b/src/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.css @@ -3,3 +3,9 @@ margin-right: float: ; } + +#MetadataAdminScreen-addField-fieldType li { + margin-right: /* @todo */ + margin-left: 10px; + float: /* Some comment. */ ; +} diff --git a/src/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.php b/src/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.php index 263909850e..f5bc858d03 100644 --- a/src/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.php +++ b/src/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.php @@ -26,8 +26,10 @@ class EmptyStyleDefinitionUnitTest extends AbstractSniffUnitTest public function getErrorList() { return [ - 3 => 1, - 4 => 1, + 3 => 1, + 4 => 1, + 8 => 1, + 10 => 1, ]; }//end getErrorList()