Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,24 @@ public function process(File $phpcsFile, $stackPtr)
return;
}

$find = Tokens::$methodPrefixes;
$find[] = T_WHITESPACE;
$ignore = Tokens::$methodPrefixes;
$ignore[T_WHITESPACE] = T_WHITESPACE;

for ($commentEnd = ($stackPtr - 1); $commentEnd >= 0; $commentEnd--) {
if (isset($ignore[$tokens[$commentEnd]['code']]) === true) {
continue;
}

if ($tokens[$commentEnd]['code'] === T_ATTRIBUTE_END
&& isset($tokens[$commentEnd]['attribute_opener']) === true
) {
$commentEnd = $tokens[$commentEnd]['attribute_opener'];
continue;
}

break;
}

$commentEnd = $phpcsFile->findPrevious($find, ($stackPtr - 1), null, true);
if ($tokens[$commentEnd]['code'] !== T_DOC_COMMENT_CLOSE_TAG) {
// Function doesn't have a doc comment or is using the wrong type of comment.
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,3 +509,17 @@ namespace {
}
}
}

$anon = new class {
/**
* Tag and token number mismatch.
*
* @throws PHP_Exception1
* @throws PHP_Exception2
*/
#[AnAttribute]
#[AnotherAttribute]
public function JumpOverAttributesToFindDocblock() {
throw new PHP_Exception1('Error');
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function getErrorList()
219 => 1,
287 => 1,
397 => 1,
519 => 1,
];

}//end getErrorList()
Expand Down