From 4b47564bfe1cd85f6c570777c6148549b5950242 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Mon, 24 Jun 2024 11:43:56 -0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20New=20WordPress.WP.GetMetaSingle=20?= =?UTF-8?q?sniff?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- WordPress-Extra/ruleset.xml | 5 + WordPress/Docs/WP/GetMetaSingleStandard.xml | 33 ++++ WordPress/Sniffs/WP/GetMetaSingleSniff.php | 172 +++++++++++++++++++ WordPress/Tests/WP/GetMetaSingleUnitTest.inc | 32 ++++ WordPress/Tests/WP/GetMetaSingleUnitTest.php | 52 ++++++ 5 files changed, 294 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 ab0e8db3b7..a1d36cc955 100644 --- a/WordPress-Extra/ruleset.xml +++ b/WordPress-Extra/ruleset.xml @@ -187,6 +187,11 @@ + + +