Skip to content

Commit 2d6b0f7

Browse files
committed
Changelog + minor reverts for #2441 (ref #2411)
1 parent f1a8e47 commit 2d6b0f7

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

package.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ http://pear.php.net/dtd/package-2.0.xsd">
2727
<license uri="https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt">BSD 3-Clause License</license>
2828
<notes>
2929
- Added support for only checking files that have been locally staged in a git repo
30-
-- Use --filter=gitstaged to check these files
31-
-- You still need to give PHPCS a list of files or directories in which to apply the filter
32-
-- Thanks to Juliette Reinders Folmer for the contribution
30+
-- Use --filter=gitstaged to check these files
31+
-- You still need to give PHPCS a list of files or directories in which to apply the filter
32+
-- Thanks to Juliette Reinders Folmer for the contribution
33+
- PSR2.ControlStructures.ControlStructureSpacing now allows whitespace after the opening parenthesis if followed by a comment
34+
-- Thanks to Michał Bundyra for the patch
3335
- Fixed bug #2478 : FunctionCommentThrowTag.WrongNumber when exception is thrown once but built conditionally
3436
- Fixed bug #2479 : Generic.WhiteSpace.ScopeIndent error when using array destructuring with exact indent checking
3537
</notes>

src/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function process(File $phpcsFile, $stackPtr)
7979
$parenOpener = $tokens[$stackPtr]['parenthesis_opener'];
8080
$parenCloser = $tokens[$stackPtr]['parenthesis_closer'];
8181
$nextContent = $phpcsFile->findNext(T_WHITESPACE, ($parenOpener + 1), null, true);
82-
if (false === in_array($tokens[$nextContent]['code'], Tokens::$commentTokens, true)) {
82+
if (in_array($tokens[$nextContent]['code'], Tokens::$commentTokens, true) === false) {
8383
$spaceAfterOpen = 0;
8484
if ($tokens[($parenOpener + 1)]['code'] === T_WHITESPACE) {
8585
if (strpos($tokens[($parenOpener + 1)]['content'], $phpcsFile->eolChar) !== false) {
@@ -102,12 +102,10 @@ public function process(File $phpcsFile, $stackPtr)
102102
$padding = str_repeat(' ', $this->requiredSpacesAfterOpen);
103103
if ($spaceAfterOpen === 0) {
104104
$phpcsFile->fixer->addContent($parenOpener, $padding);
105+
} else if ($spaceAfterOpen === 'newline') {
106+
$phpcsFile->fixer->replaceToken(($parenOpener + 1), '');
105107
} else {
106-
if ($spaceAfterOpen === 'newline') {
107-
$phpcsFile->fixer->replaceToken(($parenOpener + 1), '');
108-
} else {
109-
$phpcsFile->fixer->replaceToken(($parenOpener + 1), $padding);
110-
}
108+
$phpcsFile->fixer->replaceToken(($parenOpener + 1), $padding);
111109
}
112110
}
113111
}

0 commit comments

Comments
 (0)