function Sniff::process
Called when one of the token types that this sniff is listening for is found.
The stackPtr variable indicates where in the stack the token was found. A sniff can acquire information about this token, along with all the other tokens within the stack by first acquiring the token stack:
<code> $tokens = $phpcsFile->getTokens(); echo 'Encountered a '.$tokens[$stackPtr]['type'].' token'; echo 'token information: '; print_r($tokens[$stackPtr]); </code>
If the sniff discovers an anomaly in the code, they can raise an error by calling addError() on the \PHP_CodeSniffer\Files\File object, specifying an error message and the position of the offending token:
<code> $phpcsFile->addError('Encountered an error', $stackPtr); </code>
Parameters
\PHP_CodeSniffer\Files\File $phpcsFile The PHP_CodeSniffer file where the: token was found.
int $stackPtr The position in the PHP_CodeSniffer: file's token stack where the token was found.
Return value
void|int Optionally returns a stack pointer. The sniff will not be called again on the current file until the returned stack pointer is reached. Return `$phpcsFile->numTokens` to skip the rest of the file.
453 methods override Sniff::process()
- AbstractArraySniff::process in vendor/
squizlabs/ php_codesniffer/ src/ Sniffs/ AbstractArraySniff.php - Processes this sniff, when one of its tokens is encountered.
- AbstractClassNamePrefixSniff::process in vendor/
squizlabs/ php_codesniffer/ src/ Standards/ Generic/ Sniffs/ NamingConventions/ AbstractClassNamePrefixSniff.php - Processes this sniff, when one of its tokens is encountered.
- AbstractControlStructureSpacing::process in vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ ControlStructures/ AbstractControlStructureSpacing.php - * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *
- AbstractFullyQualifiedGlobalReference::process in vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ Namespaces/ AbstractFullyQualifiedGlobalReference.php - * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *
- AbstractPatternSniff::process in vendor/
squizlabs/ php_codesniffer/ src/ Sniffs/ AbstractPatternSniff.php - Processes the test.
File
-
vendor/
squizlabs/ php_codesniffer/ src/ Sniffs/ Sniff.php, line 77
Class
Namespace
PHP_CodeSniffer\SniffsCode
public function process(File $phpcsFile, $stackPtr);