*/ public function register() { return [\T_CLASS]; } /** * 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.1') === false) { return; } $properties = ObjectDeclarations::getClassProperties($phpcsFile, $stackPtr); if ($properties['is_readonly'] === false) { return; } $phpcsFile->addError( 'Readonly classes are not supported in PHP 8.1 or earlier.', $properties['readonly_token'], 'Found' ); } }