Skip to content

Commit

Permalink
Fixed bug #20240 : Squiz block comment sniff fails when newline present
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Apr 30, 2014
1 parent 32e103b commit 3490329
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
{ {
$tokens = $phpcsFile->getTokens(); $tokens = $phpcsFile->getTokens();


// If its an inline comment return. // If it's an inline comment, return.
if (substr($tokens[$stackPtr]['content'], 0, 2) !== '/*') { if (substr($tokens[$stackPtr]['content'], 0, 2) !== '/*') {
return; return;
} }
Expand Down Expand Up @@ -232,7 +232,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)


$commentCloser = $commentLines[$lastIndex]; $commentCloser = $commentLines[$lastIndex];
$contentAfter = $phpcsFile->findNext(T_WHITESPACE, ($commentCloser + 1), null, true); $contentAfter = $phpcsFile->findNext(T_WHITESPACE, ($commentCloser + 1), null, true);
if (($tokens[$contentAfter]['line'] - $tokens[$commentCloser]['line']) < 2) { if ($contentAfter !== false && ($tokens[$contentAfter]['line'] - $tokens[$commentCloser]['line']) < 2) {
$error = 'Empty line required after block comment'; $error = 'Empty line required after block comment';
$phpcsFile->addError($error, $commentCloser, 'NoEmptyLineAfter'); $phpcsFile->addError($error, $commentCloser, 'NoEmptyLineAfter');
} }
Expand Down
1 change: 1 addition & 0 deletions package.xml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
- Fixed bug #20213 : Invalid error, Inline IF must be declared on single line - Fixed bug #20213 : Invalid error, Inline IF must be declared on single line
- Fixed bug #20225 : array_merge() that takes more than one line generates error - Fixed bug #20225 : array_merge() that takes more than one line generates error
- Fixed bug #20230 : Squiz ControlStructureSpacing sniff assumes specific condition formatting - Fixed bug #20230 : Squiz ControlStructureSpacing sniff assumes specific condition formatting
- Fixed bug #20240 : Squiz block comment sniff fails when newline present
- Fixed bug #20247 : The Squiz.WhiteSpace.ControlStructureSpacing sniff and do-while - Fixed bug #20247 : The Squiz.WhiteSpace.ControlStructureSpacing sniff and do-while
-- Thanks to Alexander Obuhovich for the patch -- Thanks to Alexander Obuhovich for the patch
- Fixed bug #20248 : The Squiz_Sniffs_WhiteSpace_ControlStructureSpacingSniff sniff and empty scope - Fixed bug #20248 : The Squiz_Sniffs_WhiteSpace_ControlStructureSpacingSniff sniff and empty scope
Expand Down

0 comments on commit 3490329

Please sign in to comment.