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

Change subject: Sniff & fix lowercase @inheritdoc
......................................................................


Sniff & fix lowercase @inheritdoc

@inheritDoc seems to be the more official casing, per the (draft)
PSR-5 [1], recent versions of phpDocumentor [2], and Java [3]
(where the tag originates); but there is plenty of ambiguity,
with old phpDocumentor [4], PHPStorm [5] and NetBeans [6] using
the lowercase form.

The old code just ignored @inheritdoc, leading to confusing error
messages. Treat it as an error of its own instead (and auto-fix
when asked).

[1] 
https://github.com/php-fig/fig-standards/blob/master/proposed/phpdoc.md#61-making-inheritance-explicit-using-the-inheritdoc-tag
[2] https://docs.phpdoc.org/guides/inheritance.html#the-inheritdoc-tag
[3] 
http://docs.oracle.com/javase/6/docs/technotes/tools/solaris/javadoc.html#@inheritDoc
[4] 
https://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_tags.inlineinheritdoc.pkg.html
[5] https://youtrack.jetbrains.com/issue/WI-10670#comment=27-330998
[6] https://blogs.oracle.com/netbeansphp/inheritdoc-tag-support-added

Change-Id: If8dad50868f507643b71349c6788f41847f32ac9
---
M MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php
M MediaWiki/Tests/files/Commenting/commenting_function.php
M MediaWiki/Tests/files/Commenting/commenting_function.php.expect
M MediaWiki/Tests/files/Commenting/commenting_function.php.fixed
4 files changed, 26 insertions(+), 3 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 90e8975..2c5ff92 100644
--- a/MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php
+++ b/MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php
@@ -147,6 +147,13 @@
                                }
                        } elseif ( $tagText === '@inheritDoc' ) {
                                $inheritDoc = true;
+                       } elseif ( $tagText === '@inheritdoc' ) {
+                               $inheritDoc = true;
+                               $error = 'Incorrect capitalization of 
@inheritDoc';
+                               $fix = $phpcsFile->addFixableError( $error, 
$tag, 'LowercaseInheritDoc' );
+                               if ( $fix === true ) {
+                                       $phpcsFile->fixer->replaceToken( $tag, 
"@inheritDoc" );
+                               }
                        }
                }
                if ( $inheritDoc ) {
diff --git a/MediaWiki/Tests/files/Commenting/commenting_function.php 
b/MediaWiki/Tests/files/Commenting/commenting_function.php
index 4df60b6..4341489 100644
--- a/MediaWiki/Tests/files/Commenting/commenting_function.php
+++ b/MediaWiki/Tests/files/Commenting/commenting_function.php
@@ -100,6 +100,13 @@
        public function testVariablePunctation( $aBool, $anInt ) {
                return $aBool;
        }
+
+       /**
+        * @inheritdoc
+        */
+       public function testInheritWrongCase( $stuff, $more, $blah ) {
+               $blah = $more . $stuff . $blah;
+       }
 }
 
 class TestPassedExamples {
diff --git a/MediaWiki/Tests/files/Commenting/commenting_function.php.expect 
b/MediaWiki/Tests/files/Commenting/commenting_function.php.expect
index db1809e..f37b542 100644
--- a/MediaWiki/Tests/files/Commenting/commenting_function.php.expect
+++ b/MediaWiki/Tests/files/Commenting/commenting_function.php.expect
@@ -72,8 +72,10 @@
      |       |     (MediaWiki.Commenting.FunctionComment.NotPunctuationParam)
   98 | ERROR | [x] Return type should not end with punctuation ":"
      |       |     (MediaWiki.Commenting.FunctionComment.NotPunctuationReturn)
- 105 | ERROR | [ ] Only one class is allowed in a file
+ 105 | ERROR | [x] Incorrect capitalization of @inheritDoc
+     |       |     (MediaWiki.Commenting.FunctionComment.LowercaseInheritDoc)
+ 112 | ERROR | [ ] Only one class is allowed in a file
      |       |     (MediaWiki.Files.OneClassPerFile.MultipleFound)
- 172 | ERROR | [ ] Only one class is allowed in a file
+ 179 | ERROR | [ ] Only one class is allowed in a file
      |       |     (MediaWiki.Files.OneClassPerFile.MultipleFound)
-PHPCBF CAN FIX THE 28 MARKED SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX THE 29 MARKED SNIFF VIOLATIONS AUTOMATICALLY
diff --git a/MediaWiki/Tests/files/Commenting/commenting_function.php.fixed 
b/MediaWiki/Tests/files/Commenting/commenting_function.php.fixed
index 60ae018..ed5b5eb 100644
--- a/MediaWiki/Tests/files/Commenting/commenting_function.php.fixed
+++ b/MediaWiki/Tests/files/Commenting/commenting_function.php.fixed
@@ -100,6 +100,13 @@
        public function testVariablePunctation( $aBool, $anInt ) {
                return $aBool;
        }
+
+       /**
+        * @inheritDoc
+        */
+       public function testInheritWrongCase( $stuff, $more, $blah ) {
+               $blah = $more . $stuff . $blah;
+       }
 }
 
 class TestPassedExamples {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: If8dad50868f507643b71349c6788f41847f32ac9
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/tools/codesniffer
Gerrit-Branch: master
Gerrit-Owner: Gergő Tisza <gti...@wikimedia.org>
Gerrit-Reviewer: Addshore <addshorew...@gmail.com>
Gerrit-Reviewer: Legoktm <lego...@member.fsf.org>
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