From 7f766304b0654cee7c1dfa8e548f65fce197e05c Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Wed, 28 Aug 2024 02:05:46 -0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20New=20WordPress.WP.GetMetaSingle=20?= =?UTF-8?q?sniff=20(#2465)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ✨ New WordPress.WP.GetMetaSingle sniff * This sniff warns when get_*_meta() and get_metadata*() functions are used with the $meta_key/$key param, but without the $single parameter. This could lead to unexpected behavior as an array will be returned, but a string might be expected. --------- Co-authored-by: Juliette <663378+jrfnl@users.noreply.github.com> --- WordPress-Extra/ruleset.xml | 5 + WordPress/Docs/WP/GetMetaSingleStandard.xml | 39 ++++ WordPress/Sniffs/WP/GetMetaSingleSniff.php | 195 +++++++++++++++++++ WordPress/Tests/WP/GetMetaSingleUnitTest.inc | 48 +++++ WordPress/Tests/WP/GetMetaSingleUnitTest.php | 53 +++++ 5 files changed, 340 insertions(+) create mode 100644 WordPress/Docs/WP/GetMetaSingleStandard.xml create mode 100644 WordPress/Sniffs/WP/GetMetaSingleSniff.php create mode 100644 WordPress/Tests/WP/GetMetaSingleUnitTest.inc create mode 100644 WordPress/Tests/WP/GetMetaSingleUnitTest.php diff --git a/WordPress-Extra/ruleset.xml b/WordPress-Extra/ruleset.xml index ab0e8db3b..53da8be01 100644 --- a/WordPress-Extra/ruleset.xml +++ b/WordPress-Extra/ruleset.xml @@ -187,6 +187,11 @@ + + +