Skip to content

Commit 1d4c9d2

Browse files
committed
PSR2/ClassDeclaration: remove some redundant code [2]
In the original version of the sniff, only comments tokens after the close brace were ignored for the `CloseBraceSameLine` check. Since then the sniff has received numerous changes improving on that code to prevent false positives. Once such change was made in response to issue squizlabs/PHP_CodeSniffer 689, the fix adding ignoring for whitespace tokens to the code block. This makes the `$tokens[$nextContent]['content'] !== $phpcsFile->eolChar` check redundant as that condition can now never be true anymore (as it could only match on `T_WHITESPACE` tokens and those are now ignored). This change is covered by the tests previously added.
1 parent 04da558 commit 1d4c9d2

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -526,9 +526,7 @@ public function processClose(File $phpcsFile, $stackPtr)
526526
$ignoreTokens[] = T_COMMENT;
527527
$ignoreTokens[] = T_SEMICOLON;
528528
$nextContent = $phpcsFile->findNext($ignoreTokens, ($closeBrace + 1), null, true);
529-
if ($tokens[$nextContent]['content'] !== $phpcsFile->eolChar
530-
&& $tokens[$nextContent]['line'] === $tokens[$closeBrace]['line']
531-
) {
529+
if ($tokens[$nextContent]['line'] === $tokens[$closeBrace]['line']) {
532530
$type = strtolower($tokens[$stackPtr]['content']);
533531
$error = 'Closing %s brace must be on a line by itself';
534532
$data = [$type];

0 commit comments

Comments
 (0)