From 01d23a68cbe350ad65817009843f03304a3765cf Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 26 Jul 2023 18:08:32 +0200 Subject: [PATCH] Core/Extra: tweak the inclusion of the `Modernize.FunctionCalls.Dirname` sniff Follow up on 2137 As WP Core has now dropped support for PHP < 7.0, it can start using the `dirname()` `$levels` parameters. Think: ```php // PHP < 7.0. $path = dirname( dirname( dirname( __DIR__ ) ) ); // PHP 7.0+. $path = dirname( __DIR__, 3 ); ``` The `Modernize.FunctionCalls.Dirname` sniff we include also includes a check (and fixer) for that, so we can now include that sniff completely in the `Core` ruleset. For now, I'm proposing to silence the error code related to the PHP 7.0 modernization opportunity (again) for the `Extra` ruleset as not all plugins/themes will have dropped support for PHP < 7.0 yet. To be on the safe side, I'm explicitly excluding the whole sniff from the ruleset used for WPCS itself as WPCS still has a PHP 5.4 minimum. --- .phpcs.xml.dist | 3 +++ WordPress-Core/ruleset.xml | 5 +++-- WordPress-Extra/ruleset.xml | 6 ++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.phpcs.xml.dist b/.phpcs.xml.dist index 062f9d0e6a..656c8ab925 100644 --- a/.phpcs.xml.dist +++ b/.phpcs.xml.dist @@ -50,6 +50,9 @@ + + + diff --git a/WordPress-Core/ruleset.xml b/WordPress-Core/ruleset.xml index f84fcca4d2..e871818cba 100644 --- a/WordPress-Core/ruleset.xml +++ b/WordPress-Core/ruleset.xml @@ -923,8 +923,9 @@ - - + diff --git a/WordPress-Extra/ruleset.xml b/WordPress-Extra/ruleset.xml index bf753e6b95..6d32e45c65 100644 --- a/WordPress-Extra/ruleset.xml +++ b/WordPress-Extra/ruleset.xml @@ -5,6 +5,12 @@ + + + 0 + +