Skip to content

Commit e69b7f8

Browse files
authored
Merge pull request #184 from magento-commerce/imported-mattijv-magento-coding-standard-400
[Imported] Check @deprecated format only if file has comment
2 parents d0298c4 + 2f9341a commit e69b7f8

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Magento2/Sniffs/Annotation/MethodAnnotationStructureSniff.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ public function process(File $phpcsFile, $stackPtr)
5252
{
5353
$tokens = $phpcsFile->getTokens();
5454
$commentStartPtr = $phpcsFile->findPrevious(T_DOC_COMMENT_OPEN_TAG, ($stackPtr), 0);
55+
$commentEndPtr = $phpcsFile->findPrevious(T_DOC_COMMENT_CLOSE_TAG, ($stackPtr), 0);
56+
if (!$commentStartPtr) {
57+
$phpcsFile->addError('Comment block is missing', $stackPtr, 'MethodArguments');
58+
return;
59+
}
5560

5661
if ($this->PHPDocFormattingValidator->hasDeprecatedWellFormatted($commentStartPtr, $tokens) !== true) {
5762
$phpcsFile->addWarning(
@@ -62,11 +67,7 @@ public function process(File $phpcsFile, $stackPtr)
6267
'InvalidDeprecatedTagUsage'
6368
);
6469
}
65-
$commentEndPtr = $phpcsFile->findPrevious(T_DOC_COMMENT_CLOSE_TAG, ($stackPtr), 0);
66-
if (!$commentStartPtr) {
67-
$phpcsFile->addError('Comment block is missing', $stackPtr, 'MethodArguments');
68-
return;
69-
}
70+
7071
$commentCloserPtr = $tokens[$commentStartPtr]['comment_closer'];
7172
$functionPtrContent = $tokens[$stackPtr + 2]['content'];
7273
if (preg_match('/(?i)__construct/', $functionPtrContent)) {

0 commit comments

Comments
 (0)