PleaseStand has uploaded a new change for review.
https://gerrit.wikimedia.org/r/288043
Change subject: SpaceyParenthesisSniff: Don't remove last argument or array
element
......................................................................
SpaceyParenthesisSniff: Don't remove last argument or array element
Since ed6dc365286a1c4c, to allow fixing errors involving multiple existing
spaces, the token immediately preceding the closing parenthesis or bracket
is replaced with a single space. This is incorrect (and damages code) when
that token is not whitespace, so make it conditional on token type.
Though I don't know the specifics, the sniff's code appears to account for
at least some cases of multiple consecutive whitespace tokens. Further
adjustment may be necessary to handle those cases entirely correctly.
Bug: T134857
Change-Id: I3dca4c37e178760a326d771c213850dead4b2bd9
---
M MediaWiki/Sniffs/WhiteSpace/SpaceyParenthesisSniff.php
1 file changed, 5 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/tools/codesniffer
refs/changes/43/288043/1
diff --git a/MediaWiki/Sniffs/WhiteSpace/SpaceyParenthesisSniff.php
b/MediaWiki/Sniffs/WhiteSpace/SpaceyParenthesisSniff.php
index eafb60a..7e2ab83 100644
--- a/MediaWiki/Sniffs/WhiteSpace/SpaceyParenthesisSniff.php
+++ b/MediaWiki/Sniffs/WhiteSpace/SpaceyParenthesisSniff.php
@@ -155,7 +155,11 @@
'SingleSpaceBeforeCloseParenthesis'
);
if ( $fix === true ) {
- $phpcsFile->fixer->replaceToken( $stackPtr - 1, ' ' );
+ if ( $previousToken['code'] === T_WHITESPACE ) {
+ $phpcsFile->fixer->replaceToken( $stackPtr - 1,
' ' );
+ } else {
+ $phpcsFile->fixer->addContentBefore( $stackPtr,
' ' );
+ }
}
}
}
--
To view, visit https://gerrit.wikimedia.org/r/288043
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3dca4c37e178760a326d771c213850dead4b2bd9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/tools/codesniffer
Gerrit-Branch: master
Gerrit-Owner: PleaseStand <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits