function SpreadOperatorSpacingSniff::process
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *
Parameters
int $spreadOperatorPointer:
Overrides Sniff::process
File
-
vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ Operators/ SpreadOperatorSpacingSniff.php, line 37
Class
Namespace
SlevomatCodingStandard\Sniffs\OperatorsCode
public function process(File $phpcsFile, $spreadOperatorPointer) : void {
$this->spacesCountAfterOperator = SniffSettingsHelper::normalizeInteger($this->spacesCountAfterOperator);
$pointerAfterWhitespace = TokenHelper::findNextNonWhitespace($phpcsFile, $spreadOperatorPointer + 1);
$whitespace = TokenHelper::getContent($phpcsFile, $spreadOperatorPointer + 1, $pointerAfterWhitespace - 1);
if ($this->spacesCountAfterOperator === strlen($whitespace)) {
return;
}
$errorMessage = $this->spacesCountAfterOperator === 0 ? 'There must be no whitespace after spread operator.' : sprintf('There must be exactly %d whitespace%s after spread operator.', $this->spacesCountAfterOperator, $this->spacesCountAfterOperator !== 1 ? 's' : '');
$fix = $phpcsFile->addFixableError($errorMessage, $spreadOperatorPointer, self::CODE_INCORRECT_SPACES_AFTER_OPERATOR);
if (!$fix) {
return;
}
$phpcsFile->fixer
->beginChangeset();
$phpcsFile->fixer
->addContent($spreadOperatorPointer, str_repeat(' ', $this->spacesCountAfterOperator));
FixerHelper::removeBetween($phpcsFile, $spreadOperatorPointer, $pointerAfterWhitespace);
$phpcsFile->fixer
->endChangeset();
}