Skip to content

Commit b76f429

Browse files
committed
SingleSpaceAfterConstructFixer - better handling of closing parenthesis and brace
1 parent 898719e commit b76f429

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/Fixer/LanguageConstruct/SingleSpaceAfterConstructFixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens)
197197

198198
$whitespaceTokenIndex = $index + 1;
199199

200-
if (';' === $tokens[$whitespaceTokenIndex]->getContent()) {
200+
if ($tokens[$whitespaceTokenIndex]->equalsAny([';', ')', [CT::T_ARRAY_SQUARE_BRACE_CLOSE]])) {
201201
continue;
202202
}
203203

tests/Fixer/LanguageConstruct/SingleSpaceAfterConstructFixerTest.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3137,10 +3137,10 @@ public function provideFixWithPhpOpenCases()
31373137
/**
31383138
* @dataProvider provideCommentsCases
31393139
*
3140-
* @param string $expected
3141-
* @param string $input
3140+
* @param string $expected
3141+
* @param null|string $input
31423142
*/
3143-
public function testComments($expected, $input)
3143+
public function testComments($expected, $input = null)
31443144
{
31453145
$this->fixer->configure([
31463146
'constructs' => [
@@ -3170,6 +3170,15 @@ public function provideCommentsCases()
31703170
$a = 3; # 3
31713171
$a = 4; /** 4 */
31723172
echo 1;
3173+
',
3174+
];
3175+
3176+
yield 'exceptions' => [
3177+
'<?php
3178+
new Dummy(/* a */);
3179+
new Dummy(/** b */);
3180+
foo(/* c */);
3181+
$arr = [/* empty */];
31733182
',
31743183
];
31753184
}

0 commit comments

Comments
 (0)