Skip to content

Commit a375eea

Browse files
rodrigoprimojrfnl
authored andcommitted
Generic/OpeningFunctionBraceKernighanRichie: improve handling of tabs in a fixer
This commit makes a tiny performance improvement to the sniff when handling fixing code with tabs. Before this change, the sniff would need two passes of the fixer for code with one tab before the opening brace. First, it would add a space between the tab and the opening brace. Then, on a second pass, it would replace the tab and the space with just one space. Now, it replaces the tab with the space directly without the need for a second pass.
1 parent 70f8f2c commit a375eea

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
@@ -167,7 +167,7 @@ public function process(File $phpcsFile, $stackPtr)
167167
$data = [$length];
168168
$fix = $phpcsFile->addFixableError($error, $openingBrace, 'SpaceBeforeBrace', $data);
169169
if ($fix === true) {
170-
if ($length === 0 || $length === '\t') {
170+
if ($length === 0) {
171171
$phpcsFile->fixer->addContentBefore($openingBrace, ' ');
172172
} else {
173173
$phpcsFile->fixer->replaceToken(($openingBrace - 1), ' ');

0 commit comments

Comments
 (0)