function LowercaseDeclarationSniff::process
Processes this test, when one of its tokens is encountered.
Parameters
\PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.:
int $stackPtr The position of the current token in: the stack passed in $tokens.
Return value
void
Overrides Sniff::process
File
-
vendor/
squizlabs/ php_codesniffer/ src/ Standards/ Squiz/ Sniffs/ ControlStructures/ LowercaseDeclarationSniff.php, line 52
Class
Namespace
PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructuresCode
public function process(File $phpcsFile, $stackPtr) {
$tokens = $phpcsFile->getTokens();
$content = $tokens[$stackPtr]['content'];
$contentLc = strtolower($content);
if ($content !== $contentLc) {
$error = '%s keyword must be lowercase; expected "%s" but found "%s"';
$data = [
strtoupper($content),
$contentLc,
$content,
];
$fix = $phpcsFile->addFixableError($error, $stackPtr, 'FoundUppercase', $data);
if ($fix === true) {
$phpcsFile->fixer
->replaceToken($stackPtr, $contentLc);
}
}
}