function ObjectMemberCommaSniff::process
Process the tokens that this sniff is listening for.
Parameters
\PHP_CodeSniffer\Files\File $phpcsFile The file where the token was found.:
int $stackPtr The position in the stack where: the token was found.
Return value
void
Overrides Sniff::process
File
-
vendor/
squizlabs/ php_codesniffer/ src/ Standards/ Squiz/ Sniffs/ Objects/ ObjectMemberCommaSniff.php, line 50
Class
Namespace
PHP_CodeSniffer\Standards\Squiz\Sniffs\ObjectsCode
public function process(File $phpcsFile, $stackPtr) {
$tokens = $phpcsFile->getTokens();
$prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, $stackPtr - 1, null, true);
if ($tokens[$prev]['code'] === T_COMMA) {
$error = 'Last member of object must not be followed by a comma';
$fix = $phpcsFile->addFixableError($error, $prev, 'Found');
if ($fix === true) {
$phpcsFile->fixer
->replaceToken($prev, '');
}
}
}