Skip to content

Commit eca701c

Browse files
committed
Fix Comment block is missing Failure when Attribute is present after docblock
1 parent 39de3e6 commit eca701c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Magento2/Sniffs/Annotation/MethodArgumentsSniff.php

+16
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,23 @@ private function isTokenBeforeClosingCommentTagValid(string $type): bool
7070
private function validateCommentBlockExists(File $phpcsFile, int $previousCommentClosePtr, int $stackPtr): bool
7171
{
7272
$tokens = $phpcsFile->getTokens();
73+
$attributeFlag = false;
7374
for ($tempPtr = $previousCommentClosePtr + 1; $tempPtr < $stackPtr; $tempPtr++) {
75+
$tokenCode = $tokens[$tempPtr]['code'];
76+
77+
// Ignore attributes e.g. #[\ReturnTypeWillChange]
78+
if ($tokenCode === T_ATTRIBUTE_END) {
79+
$attributeFlag = false;
80+
continue;
81+
}
82+
if ($attributeFlag) {
83+
continue;
84+
}
85+
if ($tokenCode === T_ATTRIBUTE) {
86+
$attributeFlag = true;
87+
continue;
88+
}
89+
7490
if (!$this->isTokenBeforeClosingCommentTagValid($tokens[$tempPtr]['type'])) {
7591
return false;
7692
}

0 commit comments

Comments
 (0)