Umherirrender has uploaded a new change for review. ( 
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(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/tools/codesniffer 
refs/changes/68/383168/1

diff --git a/MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php 
b/MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php
index 8bd2db2..60451ba 100644
--- a/MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php
+++ b/MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php
@@ -417,9 +417,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 ffa889a..51a6863 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 a140814..5da4ae2 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)
@@ -87,4 +93,4 @@
      |       |     (MediaWiki.Files.OneClassPerFile.MultipleFound)
  197 | ERROR | [ ] Only one class is allowed in a file
      |       |     (MediaWiki.Files.OneClassPerFile.MultipleFound)
-PHPCBF CAN FIX THE 32 MARKED SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX THE 34 MARKED SNIFF VIOLATIONS AUTOMATICALLY

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ide4e4e19633d374c1d5e445ad336601d54e5f6df
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/tools/codesniffer
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <umherirrender_de...@web.de>

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

Reply via email to