Skip to content

Commit 1a39154

Browse files
committed
Make use of Common::prepareForOutput() method
1 parent 7a2a574 commit 1a39154

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use PHP_CodeSniffer\Files\File;
1313
use PHP_CodeSniffer\Sniffs\Sniff;
14+
use PHP_CodeSniffer\Util\Common;
1415
use PHP_CodeSniffer\Util\Tokens;
1516

1617
class FunctionDeclarationArgumentSpacingSniff implements Sniff
@@ -246,11 +247,12 @@ public function processBracket($phpcsFile, $openBracket)
246247
$data = [
247248
$param['name'],
248249
];
249-
$found = str_replace(["\r", "\n", "\t"], ['\r', '\n', '\t'], $gap);
250-
if ($found === $gap) {
250+
if (trim($gap, ' ') === '') {
251+
// Gap contains only space characters: report the number of spaces.
251252
$data[] = strlen($gap);
252253
} else {
253-
$data[] = '"'.$found.'"';
254+
// Gap contains more than just spaces: render these for better clarity.
255+
$data[] = '"'.Common::prepareForOutput($gap).'"';
254256
}
255257

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

0 commit comments

Comments
 (0)