Skip to content

Commit

Permalink
Removed error Squiz.Classes.ClassDeclaration.NoNewlineAfterCloseBrace…
Browse files Browse the repository at this point in the history
… (request #285)
  • Loading branch information
gsherwood committed Oct 14, 2014
1 parent 7ff3bf3 commit 7ab4d28
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
Expand Up @@ -151,22 +151,16 @@ public function processClose(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
}

if ($nextContent < $phpcsFile->numTokens) {
$nextLine = $tokens[$nextContent]['line'];
$braceLine = $tokens[$closeBrace]['line'];
if ($braceLine === $nextLine) {
$error = 'Closing brace of a %s must be followed by a single blank line';
$data = array($tokens[$stackPtr]['content']);
$phpcsFile->addError($error, $closeBrace, 'NoNewlineAfterCloseBrace', $data);
} else if ($nextLine !== ($braceLine + 2)) {
$difference = ($nextLine - $braceLine - 1);
$difference = ($tokens[$nextContent]['line'] - $tokens[$closeBrace]['line'] - 1);

This comment has been minimized.

Copy link
@aik099

aik099 Oct 14, 2014

Contributor

👍 , this is much cleaner to check both cases (0 lines and 2+ lines) in one IF statement.

if ($difference !== 1) {
$error = 'Closing brace of a %s must be followed by a single blank line; found %s';
$data = array(
$tokens[$stackPtr]['content'],
$difference,
);
$phpcsFile->addError($error, $closeBrace, 'NewlinesAfterCloseBrace', $data);
}
}//end if
}

// Check the closing brace is on it's own line, but allow
// for comments like "//end class".
Expand Down
Expand Up @@ -102,4 +102,4 @@ class CorrectClassDeclaration
// Class comment here, but wrong comment type.
class testing
{
}//end class
} /* end class */ echo 'hi';
Expand Up @@ -73,6 +73,7 @@ public function getErrorList()
92 => 1,
97 => 1,
103 => 1,
105 => 1,
);

}//end getErrorList()
Expand Down
2 changes: 2 additions & 0 deletions package.xml
Expand Up @@ -43,6 +43,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
- Squiz EmbeddedPhpSniff now checks open and close tag indents and fixes some errors
- Squiz FileCommentSniff no longer throws incorrect blank line before comment errors in JS files
- Squiz ClassDeclarationSniff now has better checking for blank lines after a closing brace
- Removed error Squiz.Classes.ClassDeclaration.NoNewlineAfterCloseBrace (request #285)
-- already handled by Squiz.Classes.ClassDeclaration.CloseBraceSameLine
- Fixed bug #280 : The --config-show option generates error when there is no config file
</notes>
<contents>
Expand Down

0 comments on commit 7ab4d28

Please sign in to comment.