Hashar has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/358567 )
Change subject: Fix WhiteSpace/SpaceAfterClosureSniff ...................................................................... Fix WhiteSpace/SpaceAfterClosureSniff Introduced in 43e009a02cc, the sniff compared token code vs content which was always a mismatch. MediaWiki/Tests/files/WhiteSpace/space_after_closure.php first test is supposedly good: 1 <?php 2 $good = function () { 3 // pass 4 }; MediaWiki/Tests/files/WhiteSpace/space_after_closure.php.expect though it was marked as expected to fail on line 2: 2 | ERROR | [x] A single space should be after the function keyword | | in closures Properly compare content of next token. While at it add a couple cases for a closure having $args. Bug: T149623 Change-Id: Id789a5d3a9da61da8fdafb3a5abeca19a8e5a469 --- M MediaWiki/Sniffs/WhiteSpace/SpaceAfterClosureSniff.php M MediaWiki/Tests/files/WhiteSpace/space_after_closure.php M MediaWiki/Tests/files/WhiteSpace/space_after_closure.php.expect M MediaWiki/Tests/files/WhiteSpace/space_after_closure.php.fixed 4 files changed, 21 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/tools/codesniffer refs/changes/67/358567/1 diff --git a/MediaWiki/Sniffs/WhiteSpace/SpaceAfterClosureSniff.php b/MediaWiki/Sniffs/WhiteSpace/SpaceAfterClosureSniff.php index 335664a..2b2e58a 100644 --- a/MediaWiki/Sniffs/WhiteSpace/SpaceAfterClosureSniff.php +++ b/MediaWiki/Sniffs/WhiteSpace/SpaceAfterClosureSniff.php @@ -41,7 +41,7 @@ $tokens = $phpcsFile->getTokens(); $next = $tokens[$stackPtr + 1]; if ( $next['code'] === T_WHITESPACE ) { - if ( $next['code'] === ' ' ) { + if ( $next['content'] === ' ' ) { return; } // It's whitespace, but not a single space. diff --git a/MediaWiki/Tests/files/WhiteSpace/space_after_closure.php b/MediaWiki/Tests/files/WhiteSpace/space_after_closure.php index 1fddfa6..6526aa8 100644 --- a/MediaWiki/Tests/files/WhiteSpace/space_after_closure.php +++ b/MediaWiki/Tests/files/WhiteSpace/space_after_closure.php @@ -3,6 +3,10 @@ // pass }; +$good_with_arg = function ( $arg ) { + // pass +}; + $bad = function() { // fail }; @@ -10,3 +14,7 @@ $alsobad = function () { // fail }; + +$bad_with_arg = function( $param ) { + // fail +}; diff --git a/MediaWiki/Tests/files/WhiteSpace/space_after_closure.php.expect b/MediaWiki/Tests/files/WhiteSpace/space_after_closure.php.expect index 53a2d33..d0b7897 100644 --- a/MediaWiki/Tests/files/WhiteSpace/space_after_closure.php.expect +++ b/MediaWiki/Tests/files/WhiteSpace/space_after_closure.php.expect @@ -1,7 +1,7 @@ - 2 | ERROR | [x] A single space should be after the function keyword - | | in closures - 6 | ERROR | [x] A single space should be after the function keyword - | | in closures 10 | ERROR | [x] A single space should be after the function keyword | | in closures + 14 | ERROR | [x] A single space should be after the function keyword + | | in closures + 18 | ERROR | [x] A single space should be after the function keyword + | | in closures PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY diff --git a/MediaWiki/Tests/files/WhiteSpace/space_after_closure.php.fixed b/MediaWiki/Tests/files/WhiteSpace/space_after_closure.php.fixed index 03cf8b2..5af358f 100644 --- a/MediaWiki/Tests/files/WhiteSpace/space_after_closure.php.fixed +++ b/MediaWiki/Tests/files/WhiteSpace/space_after_closure.php.fixed @@ -3,6 +3,10 @@ // pass }; +$good_with_arg = function ( $arg ) { + // pass +}; + $bad = function () { // fail }; @@ -10,3 +14,7 @@ $alsobad = function () { // fail }; + +$bad_with_arg = function ( $param ) { + // fail +}; -- To view, visit https://gerrit.wikimedia.org/r/358567 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id789a5d3a9da61da8fdafb3a5abeca19a8e5a469 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/tools/codesniffer Gerrit-Branch: master Gerrit-Owner: Hashar <has...@free.fr> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits