diff --git a/Magento2/Sniffs/Annotation/MethodAnnotationStructureSniff.php b/Magento2/Sniffs/Annotation/MethodAnnotationStructureSniff.php index 538f80c9..d6f7ca3c 100644 --- a/Magento2/Sniffs/Annotation/MethodAnnotationStructureSniff.php +++ b/Magento2/Sniffs/Annotation/MethodAnnotationStructureSniff.php @@ -53,7 +53,8 @@ public function process(File $phpcsFile, $stackPtr) $tokens = $phpcsFile->getTokens(); $commentStartPtr = $phpcsFile->findPrevious(T_DOC_COMMENT_OPEN_TAG, ($stackPtr), 0); $commentEndPtr = $phpcsFile->findPrevious(T_DOC_COMMENT_CLOSE_TAG, ($stackPtr), 0); - if (!$commentStartPtr) { + $prevSemicolon = $phpcsFile->findPrevious(T_SEMICOLON, $stackPtr, $commentEndPtr); + if (!$commentStartPtr || $prevSemicolon) { $phpcsFile->addError('Comment block is missing', $stackPtr, 'MethodArguments'); return; } diff --git a/Magento2/Tests/Annotation/MethodAnnotationStructureUnitTest.inc b/Magento2/Tests/Annotation/MethodAnnotationStructureUnitTest.inc index 2e0fdf0e..6402dad8 100644 --- a/Magento2/Tests/Annotation/MethodAnnotationStructureUnitTest.inc +++ b/Magento2/Tests/Annotation/MethodAnnotationStructureUnitTest.inc @@ -389,4 +389,12 @@ class MethodAnnotationFixture { return false; } + + /** @var OutputInterface */ + private $output; + + private function thisMethodHasNoDocBlock(): bool + { + return false; + } } diff --git a/Magento2/Tests/Annotation/MethodAnnotationStructureUnitTest.php b/Magento2/Tests/Annotation/MethodAnnotationStructureUnitTest.php index b4c80141..9494e2d1 100644 --- a/Magento2/Tests/Annotation/MethodAnnotationStructureUnitTest.php +++ b/Magento2/Tests/Annotation/MethodAnnotationStructureUnitTest.php @@ -31,13 +31,15 @@ public function getErrorList() 185 => 1, 227 => 1, 235 => 1, + 261 => 1, 268 => 2, 269 => 1, 277 => 1, 278 => 1, 288 => 1, 289 => 1, - 298 => 1 + 298 => 1, + 396 => 1, ]; }