Skip to content

Commit e912b6f

Browse files
committed
Simplify by using same tactic as phpcs comments
1 parent 30eac2a commit e912b6f

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

coder_sniffer/Drupal/Sniffs/Commenting/FunctionCommentSniff.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ public function process(File $phpcsFile, $stackPtr)
7878
$ignore = (Tokens::$methodPrefixes + Tokens::$phpcsCommentTokens);
7979
$ignore[T_WHITESPACE] = T_WHITESPACE;
8080
$functionCodeStart = $stackPtr;
81-
$phpstanCommentLines = 0;
8281

8382
for ($commentEnd = ($stackPtr - 1); $commentEnd >= 0; $commentEnd--) {
8483
if (isset($ignore[$tokens[$commentEnd]['code']]) === true) {
@@ -101,7 +100,7 @@ public function process(File $phpcsFile, $stackPtr)
101100
if ($tokens[$commentEnd]['code'] === T_COMMENT
102101
&& preg_match('/\@phpstan-ignore/', $tokens[$commentEnd]['content']) === 1
103102
) {
104-
$phpstanCommentLines += 1;
103+
$functionCodeStart = $commentEnd;
105104
continue;
106105
}
107106

@@ -176,7 +175,7 @@ public function process(File $phpcsFile, $stackPtr)
176175
}
177176
}//end foreach
178177

179-
if ($tokens[$commentEnd]['line'] !== ($tokens[$functionCodeStart]['line'] - 1 - $phpstanCommentLines)) {
178+
if ($tokens[$commentEnd]['line'] !== ($tokens[$functionCodeStart]['line'] - 1)) {
180179
$error = 'There must be no blank lines after the function comment';
181180
$fix = $phpcsFile->addFixableError($error, $commentEnd, 'SpacingAfter');
182181
if ($fix === true) {

0 commit comments

Comments
 (0)