Skip to content

Commit

Permalink
bug #5453 SingleSpaceAfterConstructFixer - better handling of closing…
Browse files Browse the repository at this point in the history
… parenthesis and brace (keradus)

This PR was squashed before being merged into the 2.17 branch.

Discussion
----------

SingleSpaceAfterConstructFixer - better handling of closing parenthesis and brace

closes #5448

Commits
-------

b76f429 SingleSpaceAfterConstructFixer - better handling of closing parenthesis and brace
  • Loading branch information
keradus committed Jan 19, 2021
2 parents 3b59890 + b76f429 commit dc281d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens)

$whitespaceTokenIndex = $index + 1;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3137,10 +3137,10 @@ public function provideFixWithPhpOpenCases()
/**
* @dataProvider provideCommentsCases
*
* @param string $expected
* @param string $input
* @param string $expected
* @param null|string $input
*/
public function testComments($expected, $input)
public function testComments($expected, $input = null)
{
$this->fixer->configure([
'constructs' => [
Expand Down Expand Up @@ -3170,6 +3170,15 @@ public function provideCommentsCases()
$a = 3; # 3
$a = 4; /** 4 */
echo 1;
',
];

yield 'exceptions' => [
'<?php
new Dummy(/* a */);
new Dummy(/** b */);
foo(/* c */);
$arr = [/* empty */];
',
];
}
Expand Down

0 comments on commit dc281d9

Please sign in to comment.