Skip to content

Commit 18a4579

Browse files
committed
Ensure only the relevant docblock is read
1 parent 1172711 commit 18a4579

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

Magento2/Sniffs/Annotation/MethodAnnotationStructureSniff.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ public function process(File $phpcsFile, $stackPtr)
5353
$tokens = $phpcsFile->getTokens();
5454
$commentStartPtr = $phpcsFile->findPrevious(T_DOC_COMMENT_OPEN_TAG, ($stackPtr), 0);
5555
$commentEndPtr = $phpcsFile->findPrevious(T_DOC_COMMENT_CLOSE_TAG, ($stackPtr), 0);
56-
if (!$commentStartPtr) {
56+
$prevSemicolon = $phpcsFile->findPrevious(T_SEMICOLON, $stackPtr, $commentEndPtr);
57+
if (!$commentStartPtr || $prevSemicolon) {
5758
$phpcsFile->addError('Comment block is missing', $stackPtr, 'MethodArguments');
5859
return;
5960
}

Magento2/Tests/Annotation/MethodAnnotationStructureUnitTest.inc

+8
Original file line numberDiff line numberDiff line change
@@ -389,4 +389,12 @@ class MethodAnnotationFixture
389389
{
390390
return false;
391391
}
392+
393+
/** @var OutputInterface */
394+
private $output;
395+
396+
private function thisMethodHasNoDocBlock(): bool
397+
{
398+
return false;
399+
}
392400
}

Magento2/Tests/Annotation/MethodAnnotationStructureUnitTest.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ public function getErrorList()
3131
185 => 1,
3232
227 => 1,
3333
235 => 1,
34+
261 => 1,
3435
268 => 2,
3536
269 => 1,
3637
277 => 1,
3738
278 => 1,
3839
288 => 1,
3940
289 => 1,
40-
298 => 1
41+
298 => 1,
42+
396 => 1,
4143
];
4244
}
4345

0 commit comments

Comments
 (0)