jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/383168 )

Change subject: Add sniff for @params instead of @param
......................................................................


Add sniff for @params instead of @param

Change-Id: Ide4e4e19633d374c1d5e445ad336601d54e5f6df
---
M MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php
M MediaWiki/Tests/files/Commenting/commenting_function.php
M MediaWiki/Tests/files/Commenting/commenting_function.php.expect
3 files changed, 20 insertions(+), 4 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php 
b/MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php
index 0debd9e..1e39fcf 100644
--- a/MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php
+++ b/MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php
@@ -420,9 +420,19 @@
                $maxType = 0;
                $maxVar = 0;
                foreach ( $tokens[$commentStart]['comment_tags'] as $pos => 
$tag ) {
-                       if ( $tokens[$tag]['content'] !== '@param' ) {
+                       $tagContent = $tokens[$tag]['content'];
+                       if ( $tagContent !== '@param' && $tagContent !== 
'@params' ) {
                                continue;
                        }
+
+                       if ( $tagContent === '@params' ) {
+                               $error = 'Use @param tag in function comment 
instead of @params';
+                               $fix = $phpcsFile->addFixableError( $error, 
$tag, 'PluralParams' );
+                               if ( $fix === true ) {
+                                       $phpcsFile->fixer->replaceToken( $tag, 
'@param' );
+                               }
+                       }
+
                        $paramSpace = 0;
                        $type = '';
                        $typeSpace = 0;
diff --git a/MediaWiki/Tests/files/Commenting/commenting_function.php 
b/MediaWiki/Tests/files/Commenting/commenting_function.php
index a09fd43..51dba00 100644
--- a/MediaWiki/Tests/files/Commenting/commenting_function.php
+++ b/MediaWiki/Tests/files/Commenting/commenting_function.php
@@ -93,8 +93,8 @@
        }
 
        /**
-        * @param bool $aBool A bool
-        * @param int $anInt An int
+        * @params bool $aBool A bool
+        * @params int $anInt An int
         * @returns bool And some text
         * @throw \Exception
         * @cover this::testTagTypos()
diff --git a/MediaWiki/Tests/files/Commenting/commenting_function.php.expect 
b/MediaWiki/Tests/files/Commenting/commenting_function.php.expect
index 94b65e6..7fa3bf6 100644
--- a/MediaWiki/Tests/files/Commenting/commenting_function.php.expect
+++ b/MediaWiki/Tests/files/Commenting/commenting_function.php.expect
@@ -66,6 +66,12 @@
      |       |     
(MediaWiki.Commenting.FunctionComment.SpacingBeforeReturnType)
   89 | ERROR | [x] Expected 1 spaces after return type; 4 found
      |       |     
(MediaWiki.Commenting.FunctionComment.SpacingAfterReturnType)
+  96 | ERROR | [x] Use @param tag in function comment instead of
+     |       |     @params
+     |       |     (MediaWiki.Commenting.FunctionComment.PluralParams)
+  97 | ERROR | [x] Use @param tag in function comment instead of
+     |       |     @params
+     |       |     (MediaWiki.Commenting.FunctionComment.PluralParams)
   98 | ERROR | [x] Use @return tag in function comment instead of
      |       |     @returns
      |       |     (MediaWiki.Commenting.FunctionComment.PluralReturns)
@@ -157,4 +163,4 @@
      |       |     (MediaWiki.Files.OneClassPerFile.MultipleFound)
  240 | ERROR | [ ] Only one class is allowed in a file
      |       |     (MediaWiki.Files.OneClassPerFile.MultipleFound)
-PHPCBF CAN FIX THE 65 MARKED SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX THE 67 MARKED SNIFF VIOLATIONS AUTOMATICALLY

-- 
To view, visit https://gerrit.wikimedia.org/r/383168
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ide4e4e19633d374c1d5e445ad336601d54e5f6df
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/tools/codesniffer
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <umherirrender_de...@web.de>
Gerrit-Reviewer: Addshore <addshorew...@gmail.com>
Gerrit-Reviewer: Legoktm <lego...@member.fsf.org>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>
Gerrit-Reviewer: Umherirrender <umherirrender_de...@web.de>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to