Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SingleSpaceAfterConstructFixer - better handling of closing parenthesis and brace #5453

Merged
merged 1 commit into from
Jan 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 */);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about foo('x'/* c */, 'y'); ?

I think it still enforces space after */ which is againt every convention

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$arr = [/* empty */];
',
];
}
Expand Down