Skip to content

Commit

Permalink
Merge branch 'feature/squiz-css-emptystyle-allow-for-comments' of htt…
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Nov 29, 2017
2 parents d281f37 + fbb04ca commit 4f15b1b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use PHP_CodeSniffer\Sniffs\Sniff;
use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Util\Tokens;

class EmptyStyleDefinitionSniff implements Sniff
{
Expand Down Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@
margin-right:
float: ;
}

#MetadataAdminScreen-addField-fieldType li {
margin-right: /* @todo */
margin-left: 10px;
float: /* Some comment. */ ;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 4f15b1b

Please sign in to comment.