[MediaWiki-commits] [Gerrit] mediawiki...codesniffer[master]: Don't require @return annotations for plain "return; "
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/327441 ) Change subject: Don't require @return annotations for plain "return;" .. Don't require @return annotations for plain "return;" Change-Id: I67731467e43052a97c66fac8ffb2e1ee03eb0238 --- 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, 32 insertions(+), 0 deletions(-) Approvals: Krinkle: Looks good to me, approved jenkins-bot: Verified diff --git a/MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php b/MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php index fa3464f..60b2afe 100644 --- a/MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php +++ b/MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php @@ -113,6 +113,14 @@ if ( $returnToken === false ) { return; } + + while ( isset( $tokens[$returnToken+1] ) && $tokens[$returnToken+1]['code'] === T_SEMICOLON ) { + $returnToken = $phpcsFile->findNext( T_RETURN, $returnToken + 1, $endFunction ); + if ( $returnToken === false ) { + return; + } + } + $return = null; foreach ( $tokens[$commentStart]['comment_tags'] as $tag ) { if ( $tokens[$tag]['content'] === '@return' ) { diff --git a/MediaWiki/Tests/files/Commenting/commenting_function.php b/MediaWiki/Tests/files/Commenting/commenting_function.php index 15563b9..ffe62f1 100644 --- a/MediaWiki/Tests/files/Commenting/commenting_function.php +++ b/MediaWiki/Tests/files/Commenting/commenting_function.php @@ -32,6 +32,18 @@ public function __construct( $a ) { $this->test( $a ); } + + /** +* A blank return does not require a return tag +*/ + public function emptyReturn() { + if ( $fooBar ) { + return; + } + + baz(); + } + /** * Single Test function. * diff --git a/MediaWiki/Tests/files/Commenting/commenting_function.php.fixed b/MediaWiki/Tests/files/Commenting/commenting_function.php.fixed index ef12d1e..96b2041 100644 --- a/MediaWiki/Tests/files/Commenting/commenting_function.php.fixed +++ b/MediaWiki/Tests/files/Commenting/commenting_function.php.fixed @@ -32,6 +32,18 @@ public function __construct( $a ) { $this->test( $a ); } + + /** +* A blank return does not require a return tag +*/ + public function emptyReturn() { + if ( $fooBar ) { + return; + } + + baz(); + } + /** * Single Test function. * -- To view, visit https://gerrit.wikimedia.org/r/327441 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I67731467e43052a97c66fac8ffb2e1ee03eb0238 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/tools/codesniffer Gerrit-Branch: master Gerrit-Owner: Legoktm Gerrit-Reviewer: Krinkle Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] mediawiki...codesniffer[master]: Don't require @return annotations for plain "return; "
Legoktm has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/327441 ) Change subject: Don't require @return annotations for plain "return;" .. Don't require @return annotations for plain "return;" Change-Id: I67731467e43052a97c66fac8ffb2e1ee03eb0238 --- 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, 32 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/tools/codesniffer refs/changes/41/327441/1 diff --git a/MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php b/MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php index fa3464f..60b2afe 100644 --- a/MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php +++ b/MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php @@ -113,6 +113,14 @@ if ( $returnToken === false ) { return; } + + while ( isset( $tokens[$returnToken+1] ) && $tokens[$returnToken+1]['code'] === T_SEMICOLON ) { + $returnToken = $phpcsFile->findNext( T_RETURN, $returnToken + 1, $endFunction ); + if ( $returnToken === false ) { + return; + } + } + $return = null; foreach ( $tokens[$commentStart]['comment_tags'] as $tag ) { if ( $tokens[$tag]['content'] === '@return' ) { diff --git a/MediaWiki/Tests/files/Commenting/commenting_function.php b/MediaWiki/Tests/files/Commenting/commenting_function.php index 15563b9..ffe62f1 100644 --- a/MediaWiki/Tests/files/Commenting/commenting_function.php +++ b/MediaWiki/Tests/files/Commenting/commenting_function.php @@ -32,6 +32,18 @@ public function __construct( $a ) { $this->test( $a ); } + + /** +* A blank return does not require a return tag +*/ + public function emptyReturn() { + if ( $fooBar ) { + return; + } + + baz(); + } + /** * Single Test function. * diff --git a/MediaWiki/Tests/files/Commenting/commenting_function.php.fixed b/MediaWiki/Tests/files/Commenting/commenting_function.php.fixed index ef12d1e..96b2041 100644 --- a/MediaWiki/Tests/files/Commenting/commenting_function.php.fixed +++ b/MediaWiki/Tests/files/Commenting/commenting_function.php.fixed @@ -32,6 +32,18 @@ public function __construct( $a ) { $this->test( $a ); } + + /** +* A blank return does not require a return tag +*/ + public function emptyReturn() { + if ( $fooBar ) { + return; + } + + baz(); + } + /** * Single Test function. * -- To view, visit https://gerrit.wikimedia.org/r/327441 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I67731467e43052a97c66fac8ffb2e1ee03eb0238 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/tools/codesniffer Gerrit-Branch: master Gerrit-Owner: Legoktm ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits