From 0908bf5182b830c302199037070292e20d9f4ea6 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Wed, 30 Aug 2023 17:50:59 +0200 Subject: [PATCH] Update to WPCS v3 (#240) * Update to wp-cli-tests v4 (which requires WPCS v3) * Fix all autofixable CS issues * Avoid nested control structure * Fix linting issue --------- Co-authored-by: Daniel Bachhuber --- composer.json | 2 +- db-command.php | 2 +- src/DB_Command.php | 8 +++----- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 5ab921f9f..a6eccae43 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ }, "require-dev": { "wp-cli/entity-command": "^1.3 || ^2", - "wp-cli/wp-cli-tests": "^3.1" + "wp-cli/wp-cli-tests": "^4" }, "config": { "process-timeout": 7200, diff --git a/db-command.php b/db-command.php index 2e3e54e19..d08f55bb9 100644 --- a/db-command.php +++ b/db-command.php @@ -4,7 +4,7 @@ return; } -$wpcli_db_autoloader = dirname( __FILE__ ) . '/vendor/autoload.php'; +$wpcli_db_autoloader = __DIR__ . '/vendor/autoload.php'; if ( file_exists( $wpcli_db_autoloader ) ) { require_once $wpcli_db_autoloader; } diff --git a/src/DB_Command.php b/src/DB_Command.php index 3161e7c2c..1086fdecf 100644 --- a/src/DB_Command.php +++ b/src/DB_Command.php @@ -1114,7 +1114,7 @@ public function size( $args, $assoc_args ) { if ( $orderby ) { usort( $rows, - function( $a, $b ) use ( $order, $orderby ) { + function ( $a, $b ) use ( $order, $orderby ) { $orderby_array = 'asc' === $order ? array( $a, $b ) : array( $b, $a ); list( $first, $second ) = $orderby_array; @@ -1373,11 +1373,9 @@ public function search( $args, $assoc_args ) { if ( ! $text_columns ) { if ( $stats ) { $skipped[] = $table; - } else { // Don't bother warning for term relationships (which is just 3 int columns). - if ( ! preg_match( '/_term_relationships$/', $table ) ) { - WP_CLI::warning( $primary_keys ? "No text columns for table '$table' - skipped." : "No primary key or text columns for table '$table' - skipped." ); - } + } elseif ( ! preg_match( '/_term_relationships$/', $table ) ) { + WP_CLI::warning( $primary_keys ? "No text columns for table '$table' - skipped." : "No primary key or text columns for table '$table' - skipped." ); } continue; }