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

Change subject: Don't require documentation for '__toString'
......................................................................


Don't require documentation for '__toString'

Bug: T164650
Change-Id: I6d976402e3cf56b96be9a304270591c0ac0b45f5
---
M MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php
M MediaWiki/Tests/files/Commenting/commenting_function.php
M MediaWiki/Tests/files/Commenting/commenting_function.php.fixed
3 files changed, 13 insertions(+), 0 deletions(-)

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



diff --git a/MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php 
b/MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php
index 3cc5a5f..8ed7d91 100644
--- a/MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php
+++ b/MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php
@@ -44,6 +44,11 @@
                        return;
                }
                $tokens = $phpcsFile->getTokens();
+               $funcName = $tokens[$stackPtr+2];
+               if ( $funcName['content'] === '__toString' ) {
+                       // Don't require documentation for an obvious method
+                       return;
+               }
                // Identify the visiblity of the function
                $visibility = $phpcsFile->findPrevious( [ T_PUBLIC, 
T_PROTECTED, T_PRIVATE ], $stackPtr - 1 );
                $visStr = 'Public';
diff --git a/MediaWiki/Tests/files/Commenting/commenting_function.php 
b/MediaWiki/Tests/files/Commenting/commenting_function.php
index de1fa48..e626088 100644
--- a/MediaWiki/Tests/files/Commenting/commenting_function.php
+++ b/MediaWiki/Tests/files/Commenting/commenting_function.php
@@ -59,4 +59,8 @@
                // it is private
                echo $foo;
        }
+
+       public function __toString() {
+               return 'no documentation because obvious';
+       }
 }
diff --git a/MediaWiki/Tests/files/Commenting/commenting_function.php.fixed 
b/MediaWiki/Tests/files/Commenting/commenting_function.php.fixed
index 735f9be..4eb3313 100644
--- a/MediaWiki/Tests/files/Commenting/commenting_function.php.fixed
+++ b/MediaWiki/Tests/files/Commenting/commenting_function.php.fixed
@@ -59,4 +59,8 @@
                // it is private
                echo $foo;
        }
+
+       public function __toString() {
+               return 'no documentation because obvious';
+       }
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I6d976402e3cf56b96be9a304270591c0ac0b45f5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/tools/codesniffer
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to