Skip to content

Commit 9a70b2f

Browse files
committed
Squiz FunctionCommentThrowTagSniff now ignores non-docblock comments
1 parent aa3447e commit 9a70b2f

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,8 @@ protected function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $sta
7373

7474
$commentEnd = $phpcsFile->findPrevious($find, ($currScope - 1), null, true);
7575
if ($tokens[$commentEnd]['code'] === T_COMMENT) {
76-
// Inline comments might just be closing comments for
77-
// control structures or functions instead of function comments
78-
// using the wrong comment type. If there is other code on the line,
79-
// assume they relate to that code.
80-
$prev = $phpcsFile->findPrevious($find, ($commentEnd - 1), null, true);
81-
if ($prev !== false && $tokens[$prev]['line'] === $tokens[$commentEnd]['line']) {
82-
$commentEnd = $prev;
83-
}
76+
// Function is using the wrong type of comment.
77+
return;
8478
}
8579

8680
if ($tokens[$commentEnd]['code'] !== T_DOC_COMMENT_CLOSE_TAG

CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.inc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,4 +268,11 @@ class Test
268268
throw new \RuntimeException('The $this->folderName must be specified before proceeding.');
269269
}
270270
}
271+
272+
/*
273+
*
274+
*/
275+
protected function foo()
276+
{
277+
}
271278
}

package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
4949
- Renamed Squiz.CSS.Opacity.SpacingAfterPoint to Squiz.CSS.Opacity.DecimalPrecision
5050
-- Please update your ruleset if you are referencing this error code directly
5151
- Squiz CSS IndentationSniff no longer assumes the class opening brace is at the end of a line
52+
- Squiz FunctionCommentThrowTagSniff now ignores non-docblock comments
5253
- Fixed bug #872 : Incorrect detection of blank lines between CSS class names
5354
</notes>
5455
<contents>

0 commit comments

Comments
 (0)