Skip to content

Commit df21713

Browse files
committed
Squiz/FunctionDeclarationArgumentSpacing: exclude space from prepareForOutput()
The `SpacingAfterHint` error uses `Common::prepareForOutput()` to make whitespace characters visible in the error message when the gap between a type hint and argument contains tabs or newlines. Among other things, the method replaces spaces with a UTF-8 middot character. This commit changes the call to `Common::prepareForOutput()`, to pass `[' ']` as the `$exclude` parameter so that spaces are displayed as-is while tabs and newlines continue to be rendered as `\t` and `\n`. This change is necessary because the middot character in the output can break tools that pipe PHPCS output through non-UTF-8 environments (see squizlabs/PHP_CodeSniffer 2652). `Common::prepareForOutput()` was added to this sniff in PR 620.
1 parent 9fdbd6e commit df21713

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ public function processBracket(File $phpcsFile, int $openBracket)
280280
$data[] = strlen($gap);
281281
} else {
282282
// Gap contains more than just spaces: render these for better clarity.
283-
$data[] = '"' . Common::prepareForOutput($gap) . '"';
283+
$data[] = '"' . Common::prepareForOutput($gap, [' ']) . '"';
284284
}
285285

286286
$fix = $phpcsFile->addFixableError($error, $typeHintToken, 'SpacingAfterHint', $data);

0 commit comments

Comments
 (0)