From b86e8808e5c3854442342db48681cfc78226ae8b Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Tue, 26 Nov 2024 11:23:34 +0545 Subject: [PATCH] Unique error code for each matched token --- .../Sniffs/CodeAnalysis/RequiredFunctionParametersSniff.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/phpcs-sniffs/PluginCheck/Sniffs/CodeAnalysis/RequiredFunctionParametersSniff.php b/phpcs-sniffs/PluginCheck/Sniffs/CodeAnalysis/RequiredFunctionParametersSniff.php index 61200990a..f81addfa9 100644 --- a/phpcs-sniffs/PluginCheck/Sniffs/CodeAnalysis/RequiredFunctionParametersSniff.php +++ b/phpcs-sniffs/PluginCheck/Sniffs/CodeAnalysis/RequiredFunctionParametersSniff.php @@ -10,6 +10,7 @@ namespace PluginCheckCS\PluginCheck\Sniffs\CodeAnalysis; +use PHPCSUtils\Utils\MessageHelper; use PHPCSUtils\Utils\PassedParameters; use WordPressCS\WordPress\AbstractFunctionParameterSniff; @@ -70,10 +71,12 @@ public function process_parameters( $stackPtr, $group_name, $matched_content, $p $found_param = PassedParameters::getParameterFromStack( $parameters, $target_param['position'], $target_param['name'] ); if ( false === $found_param ) { + $error_code = MessageHelper::stringToErrorCode( $matched_content . '_' . $target_param['name'], true ); + $this->phpcsFile->addError( 'The "%s" parameter for function %s() is missing.', $stackPtr, - 'Missing', + $error_code . 'Missing', array( $target_param['name'], $matched_content ) ); }