Skip to content

Commit

Permalink
Unique error code for each matched token
Browse files Browse the repository at this point in the history
  • Loading branch information
ernilambar committed Nov 26, 2024
1 parent f8ac867 commit b86e880
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace PluginCheckCS\PluginCheck\Sniffs\CodeAnalysis;

use PHPCSUtils\Utils\MessageHelper;
use PHPCSUtils\Utils\PassedParameters;
use WordPressCS\WordPress\AbstractFunctionParameterSniff;

Expand Down Expand Up @@ -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 )
);
}
Expand Down

0 comments on commit b86e880

Please sign in to comment.