*/ public function register() { return [\T_FUNCTION]; } /** * Processes this test, when one of its tokens is encountered. * * @since 9.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::shouldRunOnOrAbove('7.3') === false) { return; } $funcName = FunctionDeclarations::getName($phpcsFile, $stackPtr); if (\strtolower($funcName) !== 'assert') { return; } if (Scopes::isOOMethod($phpcsFile, $stackPtr) === true) { return; } if (Namespaces::determineNamespace($phpcsFile, $stackPtr) === '') { // Not a namespaced function declaration. This may be a parse error, but not our concern. return; } $error = 'Declaring a namespaced function called assert() is deprecated since PHP 7.3'; $code = 'Deprecated'; $isError = false; if (ScannedCode::shouldRunOnOrAbove('8.0') === true) { $error .= ' and will throw a fatal error since PHP 8.0'; $code = 'Removed'; $isError = true; } MessageHelper::addMessage($phpcsFile, $error, $stackPtr, $isError, $code); } }