Skip to content

Commit dd5f253

Browse files
authored
Merge pull request #142 from jrfnl/feature/minor-cs-tweaks
PHPCS: minor tweaks
2 parents 086db77 + 9049d20 commit dd5f253

File tree

2 files changed

+34
-34
lines changed

2 files changed

+34
-34
lines changed

phpcs.xml.dist

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
4646
<properties>
4747
<property name="prefixes" type="array">
48-
<element value="WP_CLI\db"/><!-- Namespaces. -->
48+
<element value="WP_CLI\DB"/><!-- Namespaces. -->
4949
<element value="wpcli_db"/><!-- Global variables and such. -->
5050
</property>
5151
</properties>

src/DB_Command.php

+33-33
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
use WP_CLI\Formatter;
4-
use \WP_CLI\Utils;
4+
use WP_CLI\Utils;
55

66
/**
77
* Performs basic database operations using credentials stored in wp-config.php.
@@ -158,7 +158,7 @@ public function clean( $_, $assoc_args ) {
158158

159159
$mysql_args = self::get_dbuser_dbpass_args( $assoc_args );
160160

161-
$tables = WP_CLI\Utils\wp_get_table_names(
161+
$tables = Utils\wp_get_table_names(
162162
array(),
163163
array( 'all-tables-with-prefix' )
164164
);
@@ -374,7 +374,7 @@ public function cli( $args, $assoc_args ) {
374374
public function query( $args, $assoc_args ) {
375375
$assoc_args['database'] = DB_NAME;
376376

377-
// The query might come from STDIN
377+
// The query might come from STDIN.
378378
if ( ! empty( $args ) ) {
379379
$assoc_args['execute'] = $args[0];
380380
}
@@ -471,7 +471,7 @@ public function export( $args, $assoc_args ) {
471471

472472
}
473473
$stdout = ( '-' === $result_file );
474-
$porcelain = \WP_CLI\Utils\get_flag_value( $assoc_args, 'porcelain' );
474+
$porcelain = Utils\get_flag_value( $assoc_args, 'porcelain' );
475475

476476
// Bail if both porcelain and STDOUT are set.
477477
if ( $stdout && $porcelain ) {
@@ -502,7 +502,7 @@ public function export( $args, $assoc_args ) {
502502
}
503503
}
504504

505-
$exclude_tables = WP_CLI\Utils\get_flag_value( $assoc_args, 'exclude_tables' );
505+
$exclude_tables = Utils\get_flag_value( $assoc_args, 'exclude_tables' );
506506
if ( isset( $exclude_tables ) ) {
507507
$tables = explode( ',', trim( $assoc_args['exclude_tables'], ',' ) );
508508
unset( $assoc_args['exclude_tables'] );
@@ -575,7 +575,7 @@ public function import( $args, $assoc_args ) {
575575
WP_CLI::error( sprintf( 'Import file missing or not readable: %s', $result_file ) );
576576
}
577577

578-
$query = \WP_CLI\Utils\get_flag_value( $assoc_args, 'skip-optimization' )
578+
$query = Utils\get_flag_value( $assoc_args, 'skip-optimization' )
579579
? 'SOURCE %s;'
580580
: 'SET autocommit = 0; SET unique_checks = 0; SET foreign_key_checks = 0; SOURCE %s; COMMIT;';
581581

@@ -642,14 +642,14 @@ public function import( $args, $assoc_args ) {
642642
*/
643643
public function tables( $args, $assoc_args ) {
644644

645-
$format = WP_CLI\Utils\get_flag_value( $assoc_args, 'format' );
645+
$format = Utils\get_flag_value( $assoc_args, 'format' );
646646
unset( $assoc_args['format'] );
647647

648648
if ( empty( $args ) && empty( $assoc_args ) ) {
649649
$assoc_args['scope'] = 'all';
650650
}
651651

652-
$tables = WP_CLI\Utils\wp_get_table_names( $args, $assoc_args );
652+
$tables = Utils\wp_get_table_names( $args, $assoc_args );
653653

654654
if ( 'csv' === $format ) {
655655
WP_CLI::line( implode( ',', $tables ) );
@@ -774,13 +774,13 @@ public function size( $args, $assoc_args ) {
774774

775775
global $wpdb;
776776

777-
$format = WP_CLI\Utils\get_flag_value( $assoc_args, 'format' );
778-
$size_format = WP_CLI\Utils\get_flag_value( $assoc_args, 'size_format' );
779-
$human_readable = WP_CLI\Utils\get_flag_value( $assoc_args, 'human-readable', false );
780-
$tables = WP_CLI\Utils\get_flag_value( $assoc_args, 'tables' );
777+
$format = Utils\get_flag_value( $assoc_args, 'format' );
778+
$size_format = Utils\get_flag_value( $assoc_args, 'size_format' );
779+
$human_readable = Utils\get_flag_value( $assoc_args, 'human-readable', false );
780+
$tables = Utils\get_flag_value( $assoc_args, 'tables' );
781781
$tables = ! empty( $tables );
782-
$all_tables = WP_CLI\Utils\get_flag_value( $assoc_args, 'all-tables' );
783-
$all_tables_with_prefix = WP_CLI\Utils\get_flag_value( $assoc_args, 'all-tables-with-prefix' );
782+
$all_tables = Utils\get_flag_value( $assoc_args, 'all-tables' );
783+
$all_tables_with_prefix = Utils\get_flag_value( $assoc_args, 'all-tables-with-prefix' );
784784

785785
if ( ! is_null( $size_format ) && $human_readable ) {
786786
WP_CLI::error( 'Cannot use --size_format and --human-readable arguments at the same time.' );
@@ -804,7 +804,7 @@ public function size( $args, $assoc_args ) {
804804
if ( $tables || $all_tables || $all_tables_with_prefix ) {
805805

806806
// Add all of the table sizes
807-
foreach ( WP_CLI\Utils\wp_get_table_names( $args, $assoc_args ) as $table_name ) {
807+
foreach ( Utils\wp_get_table_names( $args, $assoc_args ) as $table_name ) {
808808

809809
// Get the table size.
810810
$table_bytes = $wpdb->get_var(
@@ -840,7 +840,7 @@ public function size( $args, $assoc_args ) {
840840

841841
if ( ! empty( $size_format ) || $human_readable ) {
842842
foreach ( $rows as $index => $row ) {
843-
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound
843+
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- Backfilling WP native constants.
844844
if ( ! defined( 'KB_IN_BYTES' ) ) {
845845
define( 'KB_IN_BYTES', 1024 );
846846
}
@@ -862,7 +862,7 @@ public function size( $args, $assoc_args ) {
862862
$size_format = isset( $sizes[ $size_key ] ) ? $sizes[ $size_key ] : $sizes[0];
863863
}
864864

865-
// Display the database size as a number.
865+
// Display the database size as a number.
866866
switch ( $size_format ) {
867867
case 'TB':
868868
$divisor = pow( 1000, 4 );
@@ -1086,17 +1086,17 @@ public function search( $args, $assoc_args ) {
10861086

10871087
$search = array_shift( $args );
10881088

1089-
$before_context = \WP_CLI\Utils\get_flag_value( $assoc_args, 'before_context', 40 );
1089+
$before_context = Utils\get_flag_value( $assoc_args, 'before_context', 40 );
10901090
$before_context = '' === $before_context ? $before_context : (int) $before_context;
10911091

1092-
$after_context = \WP_CLI\Utils\get_flag_value( $assoc_args, 'after_context', 40 );
1092+
$after_context = Utils\get_flag_value( $assoc_args, 'after_context', 40 );
10931093
$after_context = '' === $after_context ? $after_context : (int) $after_context;
10941094

1095-
$regex = \WP_CLI\Utils\get_flag_value( $assoc_args, 'regex', false );
1095+
$regex = Utils\get_flag_value( $assoc_args, 'regex', false );
10961096
if ( false !== $regex ) {
1097-
$regex_flags = \WP_CLI\Utils\get_flag_value( $assoc_args, 'regex-flags', false );
1097+
$regex_flags = Utils\get_flag_value( $assoc_args, 'regex-flags', false );
10981098
$default_regex_delimiter = false;
1099-
$regex_delimiter = \WP_CLI\Utils\get_flag_value( $assoc_args, 'regex-delimiter', '' );
1099+
$regex_delimiter = Utils\get_flag_value( $assoc_args, 'regex-delimiter', '' );
11001100
if ( '' === $regex_delimiter ) {
11011101
$regex_delimiter = chr( 1 );
11021102
$default_regex_delimiter = true;
@@ -1112,10 +1112,10 @@ public function search( $args, $assoc_args ) {
11121112
)
11131113
);
11141114

1115-
$table_column_once = \WP_CLI\Utils\get_flag_value( $assoc_args, 'table_column_once', false );
1116-
$one_line = \WP_CLI\Utils\get_flag_value( $assoc_args, 'one_line', false );
1117-
$matches_only = \WP_CLI\Utils\get_flag_value( $assoc_args, 'matches_only', false );
1118-
$stats = \WP_CLI\Utils\get_flag_value( $assoc_args, 'stats', false );
1115+
$table_column_once = Utils\get_flag_value( $assoc_args, 'table_column_once', false );
1116+
$one_line = Utils\get_flag_value( $assoc_args, 'one_line', false );
1117+
$matches_only = Utils\get_flag_value( $assoc_args, 'matches_only', false );
1118+
$stats = Utils\get_flag_value( $assoc_args, 'stats', false );
11191119

11201120
$column_count = 0;
11211121
$row_count = 0;
@@ -1148,7 +1148,7 @@ public function search( $args, $assoc_args ) {
11481148
$encoding = 'UTF-8';
11491149
}
11501150

1151-
$tables = WP_CLI\Utils\wp_get_table_names( $args, $assoc_args );
1151+
$tables = Utils\wp_get_table_names( $args, $assoc_args );
11521152

11531153
$start_search_time = microtime( true );
11541154

@@ -1338,12 +1338,12 @@ public function search( $args, $assoc_args ) {
13381338
public function columns( $args, $assoc_args ) {
13391339
global $wpdb;
13401340

1341-
$format = WP_CLI\Utils\get_flag_value( $assoc_args, 'format' );
1341+
$format = Utils\get_flag_value( $assoc_args, 'format' );
13421342

1343-
WP_CLI\Utils\wp_get_table_names( array( $args[0] ), array() );
1343+
Utils\wp_get_table_names( array( $args[0] ), array() );
13441344

13451345
$columns = $wpdb->get_results(
1346-
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Asserted to be a valid table name through wp_get_table_names.
1346+
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Asserted to be a valid table name through wp_get_table_names.
13471347
'SHOW COLUMNS FROM ' . $args[0]
13481348
);
13491349

@@ -1406,11 +1406,11 @@ private static function run( $cmd, $assoc_args = array(), $descriptors = null )
14061406
*/
14071407
private static function get_dbuser_dbpass_args( $assoc_args ) {
14081408
$mysql_args = array();
1409-
$dbuser = \WP_CLI\Utils\get_flag_value( $assoc_args, 'dbuser' );
1409+
$dbuser = Utils\get_flag_value( $assoc_args, 'dbuser' );
14101410
if ( null !== $dbuser ) {
14111411
$mysql_args['dbuser'] = $dbuser;
14121412
}
1413-
$dbpass = \WP_CLI\Utils\get_flag_value( $assoc_args, 'dbpass' );
1413+
$dbpass = Utils\get_flag_value( $assoc_args, 'dbpass' );
14141414
if ( null !== $dbpass ) {
14151415
$mysql_args['dbpass'] = $dbpass;
14161416
}
@@ -1508,7 +1508,7 @@ function ( $v ) {
15081508
$color_codes_regex = '/^(?:%[' . $color_codes . '])*$/';
15091509

15101510
foreach ( array_keys( $colors ) as $color_col ) {
1511-
$col_color_flag = \WP_CLI\Utils\get_flag_value( $assoc_args, $color_col . '_color', false );
1511+
$col_color_flag = Utils\get_flag_value( $assoc_args, $color_col . '_color', false );
15121512
if ( false !== $col_color_flag ) {
15131513
if ( ! preg_match( $color_codes_regex, $col_color_flag, $matches ) ) {
15141514
WP_CLI::warning( "Unrecognized percent color code '$col_color_flag' for '{$color_col}_color'." );

0 commit comments

Comments
 (0)