Fix all autofixable CS issues

This commit is contained in:
Alain Schlesser 2023-08-30 15:24:58 +02:00
parent 5c760375cd
commit d5275f3653
No known key found for this signature in database
GPG key ID: C2188A5B63449075
12 changed files with 33 additions and 43 deletions

View file

@ -4,7 +4,7 @@ if ( ! class_exists( 'WP_CLI' ) ) {
return;
}

$wpcli_extension_autoloader = dirname( __FILE__ ) . '/vendor/autoload.php';
$wpcli_extension_autoloader = __DIR__ . '/vendor/autoload.php';
if ( file_exists( $wpcli_extension_autoloader ) ) {
require_once $wpcli_extension_autoloader;
}

View file

@ -99,7 +99,7 @@ class Plugin_AutoUpdates_Command {
continue;
}

$count++;
++$count;

if ( $enabled ) {
WP_CLI::warning(
@ -107,7 +107,7 @@ class Plugin_AutoUpdates_Command {
);
} else {
$auto_updates[] = $plugin->file;
$successes++;
++$successes;
}
}

@ -176,7 +176,7 @@ class Plugin_AutoUpdates_Command {
continue;
}

$count++;
++$count;

if ( ! $enabled ) {
WP_CLI::warning(
@ -184,7 +184,7 @@ class Plugin_AutoUpdates_Command {
);
} else {
$auto_updates = array_diff( $auto_updates, [ $plugin->file ] );
$successes++;
++$successes;
}
}


View file

@ -357,7 +357,7 @@ class Plugin_Command extends \WP_CLI\CommandWithUpgrade {
WP_CLI::warning( "Failed to activate plugin. {$message}" );
} else {
$this->active_output( $plugin->name, $plugin->file, $network_wide, 'activate' );
$successes++;
++$successes;
}
}

@ -365,7 +365,6 @@ class Plugin_Command extends \WP_CLI\CommandWithUpgrade {
$verb = $network_wide ? 'network activate' : 'activate';
Utils\report_batch_operation_results( 'plugin', $verb, count( $args ), $successes, $errors );
}

}

/**
@ -428,7 +427,7 @@ class Plugin_Command extends \WP_CLI\CommandWithUpgrade {
// Network active plugins must be explicitly deactivated.
if ( ! $network_wide && 'active-network' === $status ) {
WP_CLI::warning( "Plugin '{$plugin->name}' is network active and must be deactivated with --network flag." );
$errors++;
++$errors;
continue;
}

@ -452,7 +451,7 @@ class Plugin_Command extends \WP_CLI\CommandWithUpgrade {
}

$this->active_output( $plugin->name, $plugin->file, $network_wide, 'deactivate' );
$successes++;
++$successes;

if ( Utils\get_flag_value( $assoc_args, 'uninstall' ) ) {
WP_CLI::log( "Uninstalling '{$plugin->name}'..." );
@ -466,7 +465,6 @@ class Plugin_Command extends \WP_CLI\CommandWithUpgrade {
$verb = $network_wide ? 'network deactivate' : 'deactivate';
Utils\report_batch_operation_results( 'plugin', $verb, count( $args ), $successes, $errors );
}

}

/**
@ -511,7 +509,7 @@ class Plugin_Command extends \WP_CLI\CommandWithUpgrade {
} else {
$this->activate( array( $plugin->name ), $assoc_args );
}
$successes++;
++$successes;
}
$this->chained_command = false;
Utils\report_batch_operation_results( 'plugin', 'toggle', count( $args ), $successes, $errors );
@ -952,7 +950,7 @@ class Plugin_Command extends \WP_CLI\CommandWithUpgrade {
foreach ( $plugins as $plugin ) {
if ( is_plugin_active( $plugin->file ) && ! WP_CLI\Utils\get_flag_value( $assoc_args, 'deactivate' ) ) {
WP_CLI::warning( "The '{$plugin->name}' plugin is active." );
$errors++;
++$errors;
continue;
}

@ -997,7 +995,7 @@ class Plugin_Command extends \WP_CLI\CommandWithUpgrade {
} else {
WP_CLI::log( "Ran uninstall procedure for '$plugin->name' plugin without deleting." );
}
$successes++;
++$successes;
}
if ( ! $this->chained_command ) {
Utils\report_batch_operation_results( 'plugin', 'uninstall', count( $args ), $successes, $errors );
@ -1113,9 +1111,9 @@ class Plugin_Command extends \WP_CLI\CommandWithUpgrade {
foreach ( $this->fetcher->get_many( $args ) as $plugin ) {
if ( $this->delete_plugin( $plugin ) ) {
WP_CLI::log( "Deleted '{$plugin->name}' plugin." );
$successes++;
++$successes;
} else {
$errors++;
++$errors;
}
}
if ( ! $this->chained_command ) {

View file

@ -99,7 +99,7 @@ class Theme_AutoUpdates_Command {
continue;
}

$count++;
++$count;

if ( $enabled ) {
WP_CLI::warning(
@ -107,7 +107,7 @@ class Theme_AutoUpdates_Command {
);
} else {
$auto_updates[] = $theme->stylesheet;
$successes++;
++$successes;
}
}

@ -176,7 +176,7 @@ class Theme_AutoUpdates_Command {
continue;
}

$count++;
++$count;

if ( ! $enabled ) {
WP_CLI::warning(
@ -184,7 +184,7 @@ class Theme_AutoUpdates_Command {
);
} else {
$auto_updates = array_diff( $auto_updates, [ $theme->stylesheet ] );
$successes++;
++$successes;
}
}


View file

@ -772,7 +772,7 @@ class Theme_Command extends CommandWithUpgrade {
if ( $this->is_active_theme( $theme ) && ! $force ) {
if ( ! $all ) {
WP_CLI::warning( "Can't delete the currently active theme: $theme_slug" );
$errors++;
++$errors;
}
continue;
}
@ -780,7 +780,7 @@ class Theme_Command extends CommandWithUpgrade {
if ( $this->is_active_parent_theme( $theme ) && ! $force ) {
if ( ! $all ) {
WP_CLI::warning( "Can't delete the parent of the currently active theme: $theme_slug" );
$errors++;
++$errors;
}
continue;
}
@ -789,10 +789,10 @@ class Theme_Command extends CommandWithUpgrade {

if ( is_wp_error( $r ) ) {
WP_CLI::warning( $r );
$errors++;
++$errors;
} else {
WP_CLI::log( "Deleted '$theme_slug' theme." );
$successes++;
++$successes;
}
}
if ( ! $this->chained_command ) {

View file

@ -128,7 +128,6 @@ class Theme_Mod_Command extends WP_CLI_Command {

$formatter = new \WP_CLI\Formatter( $assoc_args, $this->fields, 'thememods' );
$formatter->display_items( $list );

}

/**
@ -215,7 +214,6 @@ class Theme_Mod_Command extends WP_CLI_Command {
$count = count( $args );
$success_message = ( 1 === $count ) ? '%d mod removed.' : '%d mods removed.';
WP_CLI::success( sprintf( $success_message, $count ) );

}

/**
@ -246,5 +244,4 @@ class Theme_Mod_Command extends WP_CLI_Command {
WP_CLI::success( "Could not update theme mod {$mod}." );
}
}

}

View file

@ -30,7 +30,7 @@ abstract class CommandWithUpgrade extends \WP_CLI_Command {
// Do not automatically check translations updates after updating plugins/themes.
add_action(
'upgrader_process_complete',
function() {
function () {
remove_action( 'upgrader_process_complete', [ 'Language_Pack_Upgrader', 'async_upgrade' ], 20 );
},
1
@ -170,7 +170,7 @@ abstract class CommandWithUpgrade extends \WP_CLI_Command {
// Don't attempt to rename ZIPs uploaded to the releases page or coming from a raw source.
&& ! preg_match( '#github\.com/[^/]+/[^/]+/(?:releases/download|raw)/#', $slug ) ) {

$filter = function( $source, $remote_source, $upgrader ) use ( $slug ) {
$filter = function ( $source, $remote_source, $upgrader ) use ( $slug ) {

$slug_dir = Utils\basename( $this->parse_url_host_component( $slug, PHP_URL_PATH ), '.zip' );

@ -202,30 +202,30 @@ abstract class CommandWithUpgrade extends \WP_CLI_Command {
if ( $filter ) {
remove_filter( 'upgrader_source_selection', $filter, 10 );
}
$successes++;
++$successes;
} else {
$errors++;
++$errors;
}
} else {
// Assume a plugin/theme slug from the WordPress.org repository has been specified.
$result = $this->install_from_repo( $slug, $assoc_args );

if ( is_null( $result ) ) {
$errors++;
++$errors;
} elseif ( is_wp_error( $result ) ) {
$key = $result->get_error_code();
if ( in_array( $key, [ 'plugins_api_failed', 'themes_api_failed' ], true )
&& ! empty( $result->error_data[ $key ] ) && in_array( $result->error_data[ $key ], [ 'N;', 'b:0;' ], true ) ) {
WP_CLI::warning( "Couldn't find '$slug' in the WordPress.org {$this->item_type} directory." );
$errors++;
++$errors;
} else {
WP_CLI::warning( "$slug: " . $result->get_error_message() );
if ( 'already_installed' !== $key ) {
$errors++;
++$errors;
}
}
} else {
$successes++;
++$successes;
}
}

@ -381,7 +381,7 @@ abstract class CommandWithUpgrade extends \WP_CLI_Command {
foreach ( $items_to_update as $item_key => $item_info ) {
if ( static::INVALID_VERSION_MESSAGE === $item_info['update'] ) {
WP_CLI::warning( "{$item_info['name']}: " . static::INVALID_VERSION_MESSAGE . '.' );
$skipped++;
++$skipped;
unset( $items_to_update[ $item_key ] );
}
}
@ -426,7 +426,7 @@ abstract class CommandWithUpgrade extends \WP_CLI_Command {
}
$upgrader = $this->get_upgrader( $assoc_args );
// Ensure the upgrader uses the download offer present in each item.
$transient_filter = function( $transient ) use ( $items_to_update ) {
$transient_filter = function ( $transient ) use ( $items_to_update ) {
foreach ( $items_to_update as $name => $item_data ) {
if ( isset( $transient->response[ $name ] ) ) {
$transient->response[ $name ]->new_version = $item_data['update_version'];
@ -467,7 +467,7 @@ abstract class CommandWithUpgrade extends \WP_CLI_Command {
'status' => ( null !== $result[ $info['update_id'] ] && ! is_wp_error( $result[ $info['update_id'] ] ) ) ? 'Updated' : 'Error',
];
if ( null === $result[ $info['update_id'] ] || is_wp_error( $result[ $info['update_id'] ] ) ) {
$errors++;
++$errors;
}
}

@ -767,5 +767,4 @@ abstract class CommandWithUpgrade extends \WP_CLI_Command {
// phpcs:ignore WordPress.WP.AlternativeFunctions.parse_url_parse_url -- parse_url will only be used in absence of wp_parse_url.
return function_exists( 'wp_parse_url' ) ? wp_parse_url( $url, $component ) : parse_url( $url, $component );
}

}

View file

@ -15,4 +15,3 @@ class DestructivePluginUpgrader extends \Plugin_Upgrader {
return parent::install_package( $args );
}
}


View file

@ -15,4 +15,3 @@ class DestructiveThemeUpgrader extends \Theme_Upgrader {
return parent::install_package( $args );
}
}


View file

@ -31,4 +31,3 @@ class Plugin extends Base {
return false;
}
}


View file

@ -64,4 +64,3 @@ class Theme extends Base {
return false;
}
}


View file

@ -28,7 +28,7 @@ trait ParsePluginNameInput {
$exclude_list = explode( ',', trim( $exclude, ',' ) );
$args = array_filter(
$args,
static function( $slug ) use ( $exclude_list ) {
static function ( $slug ) use ( $exclude_list ) {
return ! in_array( $slug, $exclude_list, true );
}
);