Skip to content

Commit

Permalink
WP/GetMetaSingle: add metric to the sniff
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfnl committed Aug 26, 2024
1 parent c73162e commit 694bdf5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions WordPress/Sniffs/WP/GetMetaSingleSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
*/
final class GetMetaSingleSniff extends AbstractFunctionParameterSniff {

/**
* The phrase to use for the metric recorded by this sniff.
*
* @var string
*/
const METRIC_NAME = 'get_*meta() function called with $single parameter';

/**
* The group name for this group of functions.
*
Expand Down Expand Up @@ -165,9 +172,12 @@ public function process_parameters( $stackPtr, $group_name, $matched_content, $p

$single = PassedParameters::getParameterFromStack( $parameters, $recommended['position'], $recommended['param_name'] );
if ( is_array( $single ) ) {
$this->phpcsFile->recordMetric( $stackPtr, self::METRIC_NAME, 'yes' );
return;
}

$this->phpcsFile->recordMetric( $stackPtr, self::METRIC_NAME, 'no' );

$tokens = $this->phpcsFile->getTokens();
$message_data = array(
$condition['param_name'],
Expand Down

0 comments on commit 694bdf5

Please sign in to comment.