Skip to content

Commit 26da214

Browse files
committed
Generic/OpeningFunctionBraceKernighanRitchie: fix error position
The `SpaceBeforeBrace` error code is about the space before the scope opener, but was being thrown on the parenthesis closer preceding it, which could be confusing when there is a type declaration between the two. Fixed now. I haven't added a test as no meaningful test can be added as the error "column" is not part of the test logic.
1 parent b0cb9c5 commit 26da214

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public function process(File $phpcsFile, $stackPtr)
168168
if ($length !== 1) {
169169
$error = 'Expected 1 space before opening brace; found %s';
170170
$data = [$length];
171-
$fix = $phpcsFile->addFixableError($error, $closeBracket, 'SpaceBeforeBrace', $data);
171+
$fix = $phpcsFile->addFixableError($error, $openingBrace, 'SpaceBeforeBrace', $data);
172172
if ($fix === true) {
173173
if ($length === 0 || $length === '\t') {
174174
$phpcsFile->fixer->addContentBefore($openingBrace, ' ');

0 commit comments

Comments
 (0)