From 7a81a8658620078bf5f2785836cb33aa382e8bb4 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Wed, 30 Aug 2023 17:54:16 +0200 Subject: [PATCH] Update to WPCS v3 (#241) * Update to wp-cli-tests v4 (which requires WPCS v3) * Fix all autofixable CS issues --- composer.json | 2 +- core-command.php | 2 +- src/Core_Command.php | 21 +++++++++++-------- .../Core/NonDestructiveCoreUpgrader.php | 1 - 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index 5e45a6f0c..ced0d581d 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "wp-cli/db-command": "^1.3 || ^2", "wp-cli/entity-command": "^1.3 || ^2", "wp-cli/extension-command": "^1.2 || ^2", - "wp-cli/wp-cli-tests": "^3.2.7" + "wp-cli/wp-cli-tests": "^4" }, "config": { "process-timeout": 7200, diff --git a/core-command.php b/core-command.php index 4c1278e2f..70dfd880c 100644 --- a/core-command.php +++ b/core-command.php @@ -4,7 +4,7 @@ return; } -$wpcli_core_autoloader = dirname( __FILE__ ) . '/vendor/autoload.php'; +$wpcli_core_autoloader = __DIR__ . '/vendor/autoload.php'; if ( file_exists( $wpcli_core_autoloader ) ) { require_once $wpcli_core_autoloader; } diff --git a/src/Core_Command.php b/src/Core_Command.php index fa51b0533..1b82223af 100644 --- a/src/Core_Command.php +++ b/src/Core_Command.php @@ -793,8 +793,14 @@ private function multisite_convert_( $assoc_args ) { } // copied from populate_network() - private static function create_initial_blog( $network_id, $blog_id, $domain, $path, - $subdomain_install, $site_user ) { + private static function create_initial_blog( + $network_id, + $blog_id, + $domain, + $path, + $subdomain_install, + $site_user + ) { global $wpdb, $current_site, $wp_rewrite; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- This is meant to replace Core functionality. @@ -1138,10 +1144,8 @@ public function update( $args, $assoc_args ) { WP_CLI::success( 'WordPress is at the latest minor release.' ); return; } - } else { - if ( ! empty( $from_api->updates ) ) { + } elseif ( ! empty( $from_api->updates ) ) { list( $update ) = $from_api->updates; - } } } elseif ( Utils\wp_version_compare( $assoc_args['version'], '<' ) || 'nightly' === $assoc_args['version'] @@ -1262,7 +1266,7 @@ public function update_db( $args, $assoc_args ) { $total = 0; $site_ids = []; foreach ( $it as $blog ) { - $total++; + ++$total; $site_ids[] = $blog->site_id; $url = $blog->domain . $blog->path; $cmd = "--url={$url} core update-db"; @@ -1285,7 +1289,7 @@ public function update_db( $args, $assoc_args ) { $message = "Database upgraded successfully on {$url}"; } WP_CLI::log( $message ); - $success++; + ++$success; } else { WP_CLI::warning( "Database failed to upgrade on {$url}" ); } @@ -1506,7 +1510,7 @@ private function cleanup_extra_files( $version_from, $version_to, $locale, $inse if ( file_exists( ABSPATH . $file ) ) { unlink( ABSPATH . $file ); WP_CLI::log( "File removed: {$file}" ); - $count++; + ++$count; } } @@ -1562,5 +1566,4 @@ function () use ( $new_zip_file ) { WP_CLI::error( 'ZipArchive failed to open ZIP file.' ); } } - } diff --git a/src/WP_CLI/Core/NonDestructiveCoreUpgrader.php b/src/WP_CLI/Core/NonDestructiveCoreUpgrader.php index dc9aac777..29d7abf39 100644 --- a/src/WP_CLI/Core/NonDestructiveCoreUpgrader.php +++ b/src/WP_CLI/Core/NonDestructiveCoreUpgrader.php @@ -13,4 +13,3 @@ public function unpack_package( $package, $delete_package = false ) { return parent::unpack_package( $package, $delete_package ); } } -