From 114a672cfa7ec3b8a84216929f69f6796ab402b5 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 26 Sep 2023 00:27:12 +0000 Subject: [PATCH] Coding Standards: Upgrade WPCS to version 3.0.0. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is an important release which makes significant changes to improve the accuracy, performance, stability and maintainability of all sniffs, as well as making WordPressCS much better at handling modern PHP. WordPressCS 3.0.0 contains breaking changes, both for people using ignore annotations, people maintaining custom rulesets, as well as for sniff developers who maintain a custom PHPCS standard based on WordPressCS. If you are an end-user or maintain a custom WordPressCS based ruleset, please start by reading the [https://github.com/WordPress/WordPress-Coding-Standards/wiki/Upgrade-Guide-to-WordPressCS-3.0.0-for-ruleset-maintainers Upgrade Guide to WordPressCS 3.0.0 for ruleset maintainers] which lists the most important changes and contains a step by step guide for upgrading. If you are a maintainer of an external standard based on WordPressCS and any of your custom sniffs are based on or extend WordPressCS sniffs, please read the [https://github.com/WordPress/WordPress-Coding-Standards/wiki/Upgrade-Guide-to-WordPressCS-3.0.0-for-Developers-of-external-standards Upgrade Guide to WordPressCS 3.0.0 for Developers]. In all cases, please read the complete changelog carefully before you upgrade. This commit: * Updates the Composer dependencies to use the new version, including updating the underlying PHP_CodeSniffer dependency to the new minimum supported version for WPCS.[[BR]] Note: the Composer PHPCS installer plugin is no longer explicitly required as it is now a dependency of WPCS, so the dependency is inherited automatically. * Updates the ruleset for WPCS 3.0.0. This includes: * Raising the memory limit to be on the safe side as WPCS 3.0.0 contains a lot more sniffs. * Removing explicit inclusions of extra rules, which have now been added to the `WordPress-Core` ruleset.. * Updating property names for select sniffs. * Updating one exclusion — the `WordPress.CodeAnalysis.AssignmentInCondition` sniff has been (partially) replaced by the `Generic.CodeAnalysis.AssignmentInCondition` sniff. * Adding one new exclusion. * Downgrades one new error to a warning.[[BR]] The `Generic.Files.OneObjectStructurePerFile` sniff enforces that there is only one OO structure declaration per file. At this time, this sniff would yield 29 errors. By downgrading the sniff to a ''warning'', the build can pass and the issues can be fixed in due time. For now, the test directory will be excluded until the issues are fixed (as the test directory CS run does not allow for warnings). * Updates ignore annotations for WPCS 3.0.0. Reference: [https://github.com/WordPress/WordPress-Coding-Standards/releases/tag/3.0.0 WPCS 3.0.0 release notes]. Follow-up to [43571], [44574], [45600], [47927]. Props jrf, jorbin, desrosj. See #59161. Built from https://develop.svn.wordpress.org/trunk@56695 git-svn-id: http://core.svn.wordpress.org/trunk@56207 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/class-wp-site-health-auto-updates.php | 2 +- wp-admin/includes/image.php | 2 +- wp-admin/plugins.php | 2 +- wp-includes/category-template.php | 2 +- wp-includes/formatting.php | 4 ++-- wp-includes/post.php | 2 +- wp-includes/version.php | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/wp-admin/includes/class-wp-site-health-auto-updates.php b/wp-admin/includes/class-wp-site-health-auto-updates.php index f8521ab2b0..85decaaad2 100644 --- a/wp-admin/includes/class-wp-site-health-auto-updates.php +++ b/wp-admin/includes/class-wp-site-health-auto-updates.php @@ -228,7 +228,7 @@ class WP_Site_Health_Auto_Updates { // Search all directories we've found for evidence of version control. foreach ( $vcs_dirs as $vcs_dir ) { foreach ( $check_dirs as $check_dir ) { - // phpcs:ignore WordPress.CodeAnalysis.AssignmentInCondition,Squiz.PHP.DisallowMultipleAssignments + // phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition,Squiz.PHP.DisallowMultipleAssignments if ( $checkout = @is_dir( rtrim( $check_dir, '\\/' ) . "/$vcs_dir" ) ) { break 2; } diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php index ad6a8f0f4b..5f9141c4d6 100644 --- a/wp-admin/includes/image.php +++ b/wp-admin/includes/image.php @@ -700,7 +700,7 @@ function wp_exif_frac2dec( $str ) { } // The denominator must not be zero. - if ( 0 == $denominator ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- Deliberate loose comparison. + if ( 0 == $denominator ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual -- Deliberate loose comparison. return 0; } diff --git a/wp-admin/plugins.php b/wp-admin/plugins.php index 13a28e127e..93f9c454ab 100644 --- a/wp-admin/plugins.php +++ b/wp-admin/plugins.php @@ -511,7 +511,7 @@ if ( $action ) { // Return early if all selected plugins already have auto-updates enabled or disabled. // Must use non-strict comparison, so that array order is not treated as significant. - if ( $new_auto_updates == $auto_updates ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison + if ( $new_auto_updates == $auto_updates ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual wp_redirect( $redirect ); exit; } diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php index bfb7f6d85c..0525ae792a 100644 --- a/wp-includes/category-template.php +++ b/wp-includes/category-template.php @@ -881,7 +881,7 @@ function wp_generate_tag_cloud( $tags, $args = '' ) { } } elseif ( isset( $args['single_text'] ) && isset( $args['multiple_text'] ) ) { // If no callback exists, look for the old-style single_text and multiple_text arguments. - // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralSingle,WordPress.WP.I18n.NonSingularStringLiteralPlural + // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralSingular,WordPress.WP.I18n.NonSingularStringLiteralPlural $translate_nooped_plural = _n_noop( $args['single_text'], $args['multiple_text'] ); } else { // This is the default for when no callback, plural, or argument is passed in. diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index f94d3170a5..bc150c8a53 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -831,7 +831,7 @@ function shortcode_unautop( $text ) { $tagregexp = implode( '|', array_map( 'preg_quote', array_keys( $shortcode_tags ) ) ); $spaces = wp_spaces_regexp(); - // phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound,WordPress.WhiteSpace.PrecisionAlignment.Found -- don't remove regex indentation + // phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound,Universal.WhiteSpace.PrecisionAlignment.Found -- don't remove regex indentation $pattern = '/' . '

' // Opening paragraph. @@ -5683,7 +5683,7 @@ function wp_basename( $path, $suffix = '' ) { return urldecode( basename( str_replace( array( '%2F', '%5C' ), '/', urlencode( $path ) ), $suffix ) ); } -// phpcs:disable WordPress.WP.CapitalPDangit.Misspelled, WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid -- 8-) +// phpcs:disable WordPress.WP.CapitalPDangit.MisspelledInComment,WordPress.WP.CapitalPDangit.MisspelledInText,WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid -- 8-) /** * Forever eliminate "Wordpress" from the planet (or at least the little bit we can influence). * diff --git a/wp-includes/post.php b/wp-includes/post.php index 696e74ed2c..197653feda 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -1382,7 +1382,7 @@ function register_post_status( $post_status, $args = array() ) { } if ( false === $args->label_count ) { - // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralSingle,WordPress.WP.I18n.NonSingularStringLiteralPlural + // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralSingular,WordPress.WP.I18n.NonSingularStringLiteralPlural $args->label_count = _n_noop( $args->label, $args->label ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index 4b98c9ac10..81f095e860 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.4-alpha-56694'; +$wp_version = '6.4-alpha-56695'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.