Skip to content

Commit

Permalink
Generic/OpeningFunctionBraceKernighanRitchie: fix error position
Browse files Browse the repository at this point in the history
The `SpaceBeforeBrace` error code is about the space before the scope opener, but was being thrown on the parenthesis closer preceeding it, which could be confusing when there is a type declaration between the two.

Fixed now.
  • Loading branch information
jrfnl committed Aug 9, 2023
1 parent a813c38 commit e24afcc
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public function process(File $phpcsFile, $stackPtr)
if ($length !== 1) {
$error = 'Expected 1 space before opening brace; found %s';
$data = [$length];
$fix = $phpcsFile->addFixableError($error, $closeBracket, 'SpaceBeforeBrace', $data);
$fix = $phpcsFile->addFixableError($error, $openingBrace, 'SpaceBeforeBrace', $data);
if ($fix === true) {
if ($length === 0 || $length === '\t') {
$phpcsFile->fixer->addContentBefore($openingBrace, ' ');
Expand Down

0 comments on commit e24afcc

Please sign in to comment.