Skip to content

Commit

Permalink
bug: Fix indentation for comment at end of function followed by a com…
Browse files Browse the repository at this point in the history
…ma (#6542)
  • Loading branch information
julienfalque committed Jan 29, 2023
1 parent fa9cc9b commit 2ed718a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Fixer/Whitespace/StatementIndentationFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ private function isCommentForControlSructureContinuation(Tokens $tokens, int $in

$index = $tokens->getNextMeaningfulToken($index);

return null !== $index && $tokens[$index]->equalsAny([[T_ELSE], [T_ELSEIF], ',']);
return null !== $index && $tokens[$index]->isGivenKind([T_ELSE, T_ELSEIF]);
}

/**
Expand Down
9 changes: 1 addition & 8 deletions tests/Fixer/Basic/BracesFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3035,14 +3035,7 @@ public static function provideFixCommentBeforeBraceCases(): iterable
} else {
echo "unknown API";
// sth
}
return $this->guess($class, $property, function (Constraint $constraint) use ($guesser) {
return $guesser->guessRequiredForConstraint($constraint);
// Fallback to false...
// ... due to sth...
}, false);
',
}',
],
[
'<?php
Expand Down
8 changes: 8 additions & 0 deletions tests/Fixer/Whitespace/StatementIndentationFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,14 @@ public function foo() {
default:
}',
];

yield 'function ending with a comment and followed by a comma' => [
'<?php
foo(function () {
bar();
// comment
}, );',
];
}

/**
Expand Down

0 comments on commit 2ed718a

Please sign in to comment.