*/ public function register() { return [\T_LNUMBER]; } /** * 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 int|void Integer stack pointer to skip forward or void to continue * normal file processing. */ public function process(File $phpcsFile, $stackPtr) { if (ScannedCode::shouldRunOnOrBelow('8.0') === false) { return; } $numberInfo = Numbers::getCompleteNumber($phpcsFile, $stackPtr); if (\stripos($numberInfo['content'], '0o') !== 0) { // Not using explicit octal notation. return; } $phpcsFile->addError( 'The explicit integer octal literal prefix "0o" is not supported in PHP 8.0 or lower. Found: %s', $stackPtr, 'Found', [$numberInfo['orig_content']] ); // Skip past the parts we've already taken into account to prevent double reporting. return ($numberInfo['last_token'] + 1); } }