diff --git a/extension-command.php b/extension-command.php index d605dedd..18b87efd 100644 --- a/extension-command.php +++ b/extension-command.php @@ -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; } diff --git a/src/Plugin_AutoUpdates_Command.php b/src/Plugin_AutoUpdates_Command.php index 5509d5df..e334c108 100644 --- a/src/Plugin_AutoUpdates_Command.php +++ b/src/Plugin_AutoUpdates_Command.php @@ -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; } } diff --git a/src/Plugin_Command.php b/src/Plugin_Command.php index c9da26aa..97dcd37c 100644 --- a/src/Plugin_Command.php +++ b/src/Plugin_Command.php @@ -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 ) { diff --git a/src/Theme_AutoUpdates_Command.php b/src/Theme_AutoUpdates_Command.php index a17f529e..985aa1a1 100644 --- a/src/Theme_AutoUpdates_Command.php +++ b/src/Theme_AutoUpdates_Command.php @@ -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; } } diff --git a/src/Theme_Command.php b/src/Theme_Command.php index 5f7c6dfa..225656b6 100644 --- a/src/Theme_Command.php +++ b/src/Theme_Command.php @@ -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 ) { diff --git a/src/Theme_Mod_Command.php b/src/Theme_Mod_Command.php index 5ec6dee4..40c870a1 100644 --- a/src/Theme_Mod_Command.php +++ b/src/Theme_Mod_Command.php @@ -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}." ); } } - } diff --git a/src/WP_CLI/CommandWithUpgrade.php b/src/WP_CLI/CommandWithUpgrade.php index 237fa5d3..d345a1e7 100755 --- a/src/WP_CLI/CommandWithUpgrade.php +++ b/src/WP_CLI/CommandWithUpgrade.php @@ -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 ); } - } diff --git a/src/WP_CLI/DestructivePluginUpgrader.php b/src/WP_CLI/DestructivePluginUpgrader.php index 854ce072..5b3e1774 100644 --- a/src/WP_CLI/DestructivePluginUpgrader.php +++ b/src/WP_CLI/DestructivePluginUpgrader.php @@ -15,4 +15,3 @@ class DestructivePluginUpgrader extends \Plugin_Upgrader { return parent::install_package( $args ); } } - diff --git a/src/WP_CLI/DestructiveThemeUpgrader.php b/src/WP_CLI/DestructiveThemeUpgrader.php index 29da13b2..699d6dc0 100644 --- a/src/WP_CLI/DestructiveThemeUpgrader.php +++ b/src/WP_CLI/DestructiveThemeUpgrader.php @@ -15,4 +15,3 @@ class DestructiveThemeUpgrader extends \Theme_Upgrader { return parent::install_package( $args ); } } - diff --git a/src/WP_CLI/Fetchers/Plugin.php b/src/WP_CLI/Fetchers/Plugin.php index a0535665..e7528e9e 100644 --- a/src/WP_CLI/Fetchers/Plugin.php +++ b/src/WP_CLI/Fetchers/Plugin.php @@ -31,4 +31,3 @@ class Plugin extends Base { return false; } } - diff --git a/src/WP_CLI/Fetchers/Theme.php b/src/WP_CLI/Fetchers/Theme.php index 4efb21fe..126d333f 100644 --- a/src/WP_CLI/Fetchers/Theme.php +++ b/src/WP_CLI/Fetchers/Theme.php @@ -64,4 +64,3 @@ class Theme extends Base { return false; } } - diff --git a/src/WP_CLI/ParsePluginNameInput.php b/src/WP_CLI/ParsePluginNameInput.php index 0ec297e5..f270c7fb 100644 --- a/src/WP_CLI/ParsePluginNameInput.php +++ b/src/WP_CLI/ParsePluginNameInput.php @@ -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 ); } );