From 694bdf514d518004cefc0a22923fedeb0091eaca Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 26 Aug 2024 17:43:42 +0200 Subject: [PATCH] WP/GetMetaSingle: add metric to the sniff --- WordPress/Sniffs/WP/GetMetaSingleSniff.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/WordPress/Sniffs/WP/GetMetaSingleSniff.php b/WordPress/Sniffs/WP/GetMetaSingleSniff.php index 129b99c56..243f27250 100644 --- a/WordPress/Sniffs/WP/GetMetaSingleSniff.php +++ b/WordPress/Sniffs/WP/GetMetaSingleSniff.php @@ -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. * @@ -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'],