*/ public function register() { return Tokens::$ooScopeTokens; } /** * 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; } $ooMethods = ObjectDeclarations::getDeclaredMethods($phpcsFile, $stackPtr); $ooMethodsLC = \array_change_key_case($ooMethods, \CASE_LOWER); if (isset($ooMethodsLC['__tostring']) === \false) { // OO construct doesn't declare a `__tostring()` method. return; } $params = FunctionDeclarations::getParameters($phpcsFile, $ooMethodsLC['__tostring']); if (empty($params)) { // Function declared without parameters. return; } $phpcsFile->addError('The __toString() magic method can no longer accept arguments since PHP 5.3', $ooMethodsLC['__tostring'], 'Declared'); } }