*/ public function register() { return [\T_ATTRIBUTE]; } /** * Processes this test, when one of its tokens is encountered. * * @since 10.0.0 * * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. * @param int $stackPtr The position of the current token in the * stack passed in $tokens. * * @return void */ public function process(File $phpcsFile, $stackPtr) { if (ScannedCode::shouldRunOnOrBelow('7.4') === false) { return; } $tokens = $phpcsFile->getTokens(); if (isset($tokens[$stackPtr]['attribute_closer']) === false) { // Live coding or parse error. Shouldn't be possible as shouldn't have retokenized in that case. return; // @codeCoverageIgnore } $phpcsFile->addError( 'Attributes are not supported in PHP 7.4 or earlier. Found: %s', $stackPtr, 'Found', [GetTokensAsString::compact($phpcsFile, $stackPtr, $tokens[$stackPtr]['attribute_closer'], true)] ); } }