Skip to content

Commit

Permalink
Improve error message text
Browse files Browse the repository at this point in the history
  • Loading branch information
fredden committed Jan 7, 2025
1 parent 1f3ed76 commit 4e97c93
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,15 @@ public function processBracket($phpcsFile, $openBracket)
$error = 'Expected 1 space between type hint and argument "%s"; %s found';
$data = [
$param['name'],
$gap,
];
$fix = $phpcsFile->addFixableError($error, $typeHintToken, 'SpacingAfterHint', $data);
$found = str_replace(["\r", "\n", "\t"], ['\r', '\n', '\t'], $gap);
if ($found === $gap) {
$data[] = strlen($gap);
} else {
$data[] = '"'.$found.'"';
}

$fix = $phpcsFile->addFixableError($error, $typeHintToken, 'SpacingAfterHint', $data);
if ($fix === true) {
$phpcsFile->fixer->beginChangeset();
$i = $typeHintToken;
Expand Down

0 comments on commit 4e97c93

Please sign in to comment.