Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function process(File $phpcsFile, int $stackPtr)
}

$error = 'Language constructs must be followed by a single space; expected 1 space between YIELD FROM found "%s"';
$data = [Common::prepareForOutput($found)];
$data = [Common::prepareForOutput($found, [' '])];

if ($hasComment === true) {
$phpcsFile->addError($error, $stackPtr, 'IncorrectYieldFromWithComment', $data);
Expand All @@ -139,8 +139,16 @@ public function process(File $phpcsFile, int $stackPtr)
if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) {
$content = $tokens[($stackPtr + 1)]['content'];
if ($content !== ' ') {
$error = 'Language constructs must be followed by a single space; expected 1 space but found "%s"';
$data = [Common::prepareForOutput($content)];
if (trim($content, ' ') === '') {
// Only space characters: report the count.
$found = $tokens[($stackPtr + 1)]['length'] . ' spaces';
} else {
// Contains tabs or newlines: make them visible.
$found = '"' . Common::prepareForOutput($content, [' ']) . '"';
}

$error = 'Language constructs must be followed by a single space; expected 1 space but found %s';
$data = [$found];
$fix = $phpcsFile->addFixableError($error, $stackPtr, 'IncorrectSingle', $data);
if ($fix === true) {
$phpcsFile->fixer->replaceToken(($stackPtr + 1), ' ');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public function processBracket(File $phpcsFile, int $openBracket)
$data[] = strlen($gap);
} else {
// Gap contains more than just spaces: render these for better clarity.
$data[] = '"' . Common::prepareForOutput($gap) . '"';
$data[] = '"' . Common::prepareForOutput($gap, [' ']) . '"';
}

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