*/ public function register() { return [\T_ELLIPSIS]; } /** * 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('8.0') === false) { return; } $tokens = $phpcsFile->getTokens(); $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); if ($tokens[$prev]['code'] !== \T_OPEN_PARENTHESIS) { return; } $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true); if ($next === false || $tokens[$next]['code'] !== \T_CLOSE_PARENTHESIS) { return; } $phpcsFile->addError( 'First class callables using the CallableExpr(...) syntax are not supported in PHP 8.0 or earlier.', $stackPtr, 'Found' ); } }