Skip to content

Commit f87d421

Browse files
PHPStan issue
1 parent e478364 commit f87d421

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

coder_sniffer/Drupal/Sniffs/Commenting/FunctionCommentSniff.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,6 @@ public function process(File $phpcsFile, $stackPtr)
101101
break;
102102
}
103103

104-
if (isset($tokens[$commentEnd]['comment_opener']) === true) {
105-
$commentStart = $tokens[$commentEnd]['comment_opener'];
106-
}
107-
108104
$methodName = $phpcsFile->getDeclarationName($stackPtr);
109105
if ($tokens[$commentEnd]['code'] !== T_DOC_COMMENT_CLOSE_TAG
110106
&& $tokens[$commentEnd]['code'] !== T_COMMENT
@@ -118,7 +114,7 @@ public function process(File $phpcsFile, $stackPtr)
118114
// Method prohibited to have docblock.
119115
$fix = $phpcsFile->addFixableError("It's forbidden to document $methodName function", $stackPtr, 'DocProhibited');
120116
if ($fix === true) {
121-
for ($i = $commentStart; $i <= $commentEnd; $i++) {
117+
for ($i = $tokens[$commentEnd]['comment_opener']; $i <= $commentEnd; $i++) {
122118
$phpcsFile->fixer->replaceToken($i, '');
123119
}
124120
}
@@ -161,6 +157,7 @@ public function process(File $phpcsFile, $stackPtr)
161157
return;
162158
}
163159

160+
$commentStart = $tokens[$commentEnd]['comment_opener'];
164161
foreach ($tokens[$commentStart]['comment_tags'] as $tag) {
165162
// This is a file comment, not a function comment.
166163
if ($tokens[$tag]['content'] === '@file') {

0 commit comments

Comments
 (0)