*/ public function register() { return [\T_FUNCTION]; } /** * Processes this test, when one of its tokens is encountered. * * @since 9.2.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('5.3') === false) { return; } $functionName = FunctionDeclarations::getName($phpcsFile, $stackPtr); if (\strtolower($functionName) !== '__tostring') { // Not the right function. return; } if (Scopes::isOOMethod($phpcsFile, $stackPtr) === false) { // Function, not method. return; } $params = FunctionDeclarations::getParameters($phpcsFile, $stackPtr); if (empty($params)) { // Function declared without parameters. return; } $phpcsFile->addError( 'The __toString() magic method can no longer accept arguments since PHP 5.3', $stackPtr, 'Declared' ); } }