diff --git a/composer.json b/composer.json index 4df73d02..55fceba2 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,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.1" + "wp-cli/wp-cli-tests": "^4" }, "config": { "process-timeout": 7200, diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 23ed3f41..daafcfad 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -32,6 +32,8 @@ + + - + diff --git a/search-replace-command.php b/search-replace-command.php index c7234438..bd2ad0e9 100644 --- a/search-replace-command.php +++ b/search-replace-command.php @@ -4,7 +4,7 @@ return; } -$wpcli_search_replace_autoloader = dirname( __FILE__ ) . '/vendor/autoload.php'; +$wpcli_search_replace_autoloader = __DIR__ . '/vendor/autoload.php'; if ( file_exists( $wpcli_search_replace_autoloader ) ) { require_once $wpcli_search_replace_autoloader; } diff --git a/src/Search_Replace_Command.php b/src/Search_Replace_Command.php index cba190a4..a8470e03 100644 --- a/src/Search_Replace_Command.php +++ b/src/Search_Replace_Command.php @@ -248,7 +248,7 @@ public function __invoke( $args, $assoc_args ) { } } $export_insert_size = Utils\get_flag_value( $assoc_args, 'export_insert_size', 50 ); - // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- See the code, this is deliberate. + // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual -- See the code, this is deliberate. if ( (int) $export_insert_size == $export_insert_size && $export_insert_size > 0 ) { $this->export_insert_size = $export_insert_size; } @@ -473,7 +473,7 @@ private function php_export_table( $table, $old, $new ) { if ( $value && ! in_array( $col, $primary_keys, true ) && ! in_array( $col, $this->skip_columns, true ) ) { $new_value = $replacer->run( $value ); if ( $new_value !== $value ) { - $col_counts[ $col ]++; + ++$col_counts[ $col ]; $value = $new_value; } } @@ -491,7 +491,7 @@ private function php_export_table( $table, $old, $new ) { $table_report[] = array( $table, $col, $col_count, 'PHP' ); } if ( $col_count ) { - $total_cols++; + ++$total_cols; $total_rows += $col_count; } } @@ -590,7 +590,7 @@ static function ( $key ) { $replacer->clear_log_data(); } - $count++; + ++$count; if ( ! $this->dry_run ) { $update_where = array(); foreach ( (array) $keys as $k => $v ) { @@ -682,10 +682,10 @@ private function write_sql_row_fields( $table, $rows ) { // Add new insert statement if needed. Before this we close the previous with semicolon and write statement to sql-file. // "Statement break" is needed: - // 1. When the loop is running every nth time (where n is insert statement size, $export_index_size). Remainder is zero also on first round, so it have to be excluded. - // $index % $export_insert_size == 0 && $index > 0 - // 2. Or when the loop is running last time - // $index == $count + // 1. When the loop is running every nth time (where n is insert statement size, $export_index_size). Remainder is zero also on first round, so it have to be excluded. + // $index % $export_insert_size == 0 && $index > 0 + // 2. Or when the loop is running last time + // $index == $count if ( ( 0 === $index % $export_insert_size && $index > 0 ) || $index === $count ) { $sql .= ";\n"; @@ -710,7 +710,7 @@ private function write_sql_row_fields( $table, $rows ) { $sql .= ",\n"; } - $index++; + ++$index; } } @@ -1043,5 +1043,4 @@ private function log_write( $col, $keys, $table, $old_bits, $new_bits ) { fwrite( $this->log_handle, "{$table_column_id_log}\n{$old_log}\n{$new_log}\n" ); } - }