*/ public function register() { return Collections::functionDeclarationTokens(); } /** * Processes this test, when one of its tokens is encountered. * * @since 7.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.0') === false) { return; } // Get all parameters from method signature. $parameters = FunctionDeclarations::getParameters($phpcsFile, $stackPtr); if (empty($parameters)) { return; } $paramNames = []; foreach ($parameters as $param) { $paramNames[$param['name']] = true; } if (\count($parameters) !== \count($paramNames)) { $phpcsFile->addError( 'Functions can not have multiple parameters with the same name since PHP 7.0', $stackPtr, 'Found' ); } } }