function SingleLineArrayWhitespaceSniff::checkWhitespaceAfterComma
1 call to SingleLineArrayWhitespaceSniff::checkWhitespaceAfterComma()
- SingleLineArrayWhitespaceSniff::process in vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ Arrays/ SingleLineArrayWhitespaceSniff.php - * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *
File
-
vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ Arrays/ SingleLineArrayWhitespaceSniff.php, line 200
Class
Namespace
SlevomatCodingStandard\Sniffs\ArraysCode
private function checkWhitespaceAfterComma(File $phpcsFile, int $comma) : void {
$tokens = $phpcsFile->getTokens();
if ($tokens[$comma + 1]['code'] !== T_WHITESPACE) {
$error = sprintf('Expected 1 space between comma and "%s", 0 found.', $tokens[$comma + 1]['content']);
$fix = $phpcsFile->addFixableError($error, $comma, self::CODE_SPACE_AFTER_COMMA);
if ($fix) {
$phpcsFile->fixer
->addContent($comma, ' ');
}
return;
}
$spaceLength = $tokens[$comma + 1]['length'];
if ($spaceLength === 1) {
return;
}
$error = sprintf('Expected 1 space between comma and "%s", %d found.', $tokens[$comma + 2]['content'], $spaceLength);
$fix = $phpcsFile->addFixableError($error, $comma, self::CODE_SPACE_AFTER_COMMA);
if (!$fix) {
return;
}
$phpcsFile->fixer
->replaceToken($comma + 1, ' ');
}