diff --git a/SymfonyCustom/Sniffs/Commenting/FunctionCommentSniff.php b/SymfonyCustom/Sniffs/Commenting/FunctionCommentSniff.php index f494cec..0a0f2f6 100644 --- a/SymfonyCustom/Sniffs/Commenting/FunctionCommentSniff.php +++ b/SymfonyCustom/Sniffs/Commenting/FunctionCommentSniff.php @@ -43,26 +43,8 @@ public function process(File $phpcsFile, $stackPtr) } } - $name = $phpcsFile->getDeclarationName($stackPtr); - $isTestFunction = strpos($name, 'test') === 0; - $isAllowedFunction = in_array($name, ['setUp', 'tearDown']); - $commentRequired = !$isTestFunction && !$isAllowedFunction; - - if (T_DOC_COMMENT_CLOSE_TAG !== $tokens[$commentEnd]['code'] - && T_COMMENT !== $tokens[$commentEnd]['code'] - ) { - $hasComment = false; - $phpcsFile->recordMetric($stackPtr, 'Function has doc comment', 'no'); - - if ($commentRequired) { - $phpcsFile->addError('Missing function doc comment', $stackPtr, 'Missing'); - - return; - } - } else { - $hasComment = true; - $phpcsFile->recordMetric($stackPtr, 'Function has doc comment', 'yes'); - } + $hasComment = T_DOC_COMMENT_CLOSE_TAG === $tokens[$commentEnd]['code'] + || T_COMMENT === $tokens[$commentEnd]['code']; if ($hasComment) { if (T_COMMENT === $tokens[$commentEnd]['code']) { diff --git a/SymfonyCustom/Tests/Commenting/FunctionCommentUnitTest.inc b/SymfonyCustom/Tests/Commenting/FunctionCommentUnitTest.inc index 210f3bb..ed81bca 100644 --- a/SymfonyCustom/Tests/Commenting/FunctionCommentUnitTest.inc +++ b/SymfonyCustom/Tests/Commenting/FunctionCommentUnitTest.inc @@ -94,3 +94,12 @@ function testToIgnore2() { $test = 42; } + +function toIgnore1() +{ + $test = 42; +} +function toIgnore2() +{ + $test = 42; +} diff --git a/SymfonyCustom/Tests/Commenting/FunctionCommentUnitTest.inc.fixed b/SymfonyCustom/Tests/Commenting/FunctionCommentUnitTest.inc.fixed index 166a3db..40b160b 100644 --- a/SymfonyCustom/Tests/Commenting/FunctionCommentUnitTest.inc.fixed +++ b/SymfonyCustom/Tests/Commenting/FunctionCommentUnitTest.inc.fixed @@ -97,3 +97,13 @@ function testToIgnore2() { $test = 42; } + +function toIgnore1() +{ + $test = 42; +} + +function toIgnore2() +{ + $test = 42; +} diff --git a/SymfonyCustom/Tests/Commenting/FunctionCommentUnitTest.php b/SymfonyCustom/Tests/Commenting/FunctionCommentUnitTest.php index 366634e..9982df8 100644 --- a/SymfonyCustom/Tests/Commenting/FunctionCommentUnitTest.php +++ b/SymfonyCustom/Tests/Commenting/FunctionCommentUnitTest.php @@ -22,13 +22,14 @@ class FunctionCommentUnitTest extends AbstractSniffUnitTest public function getErrorList() { return array( - 5 => 1, - 10 => 2, - 43 => 1, - 48 => 2, - 76 => 2, - 83 => 1, - 93 => 1, + 5 => 1, + 10 => 2, + 43 => 1, + 48 => 2, + 76 => 2, + 83 => 1, + 93 => 1, + 102 => 1, ); }