Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Plugin_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,10 @@ private function get_plugin_dependencies( $slug ) {
return [];
}

/**
* @var object{requires_plugins?: array} $api
*/

// Check if requires_plugins field exists and is not empty
if ( ! empty( $api->requires_plugins ) && is_array( $api->requires_plugins ) ) {
return $api->requires_plugins;
Comment thread
swissspidy marked this conversation as resolved.
Expand Down
13 changes: 12 additions & 1 deletion src/WP_CLI/CommandWithUpgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ abstract protected function get_item_list();
*/
abstract protected function filter_item_list( $items, $args );

/**
* @return array<string, array{slug: string, name: string, update: string, recently_active?: bool, status: string, version: string}>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The keys in this PHPDoc annotation don't seem to match what the implementing methods (Plugin_Command::get_all_items and Theme_Command::get_all_items) return. Those methods return an array with a name key for the slug and a title key for the human-readable name. This annotation uses slug and name respectively, which is inconsistent. To accurately reflect the returned data structure and avoid confusion, it would be better to use name and title in the annotation.

 * @return array<string, array{name: string, title: string, update: string, recently_active?: bool, status: string, version: string}>

*/
abstract protected function get_all_items();
Comment thread
swissspidy marked this conversation as resolved.

/**
Expand Down Expand Up @@ -237,6 +240,11 @@ public function install( $args, $assoc_args ) {
&& ! preg_match( '#github\.com/[^/]+/[^/]+/(?:releases/download|raw)/#', $slug ) ) {

$filter = function ( $source ) use ( $slug ) {
/**
* @var \WP_Filesystem_Base $wp_filesystem
*/
global $wp_filesystem;

/**
* @var string $path
*/
Expand All @@ -255,7 +263,7 @@ public function install( $args, $assoc_args ) {
}
$new_path = substr_replace( $source, $slug_dir, (int) strrpos( $source, $source_dir ), strlen( $source_dir ) );

if ( $GLOBALS['wp_filesystem']->move( $source, $new_path ) ) {
if ( $wp_filesystem->move( $source, $new_path ) ) {
WP_CLI::log( sprintf( "Renamed Github-based project from '%s' to '%s'.", $source_dir, $slug_dir ) );
return $new_path;
}
Expand Down Expand Up @@ -874,6 +882,9 @@ protected function _search( $args, $assoc_args ) {
// In older WP versions these used to be objects.
foreach ( $items as $index => $item_object ) {
if ( is_array( $item_object ) ) {
/**
* @var array{slug: string} $item_object
*/
$items[ $index ]['url'] = "https://wordpress.org/{$plural}/{$item_object['slug']}/";
} elseif ( $item_object instanceof \stdClass ) {
$item_object->url = "https://wordpress.org/{$plural}/{$item_object->slug}/";
Expand Down
4 changes: 4 additions & 0 deletions src/WP_CLI/ExtensionUpgraderSkin.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@
* An Upgrader Skin for extensions (plugins/themes) that displays which item is being updated
*
* @package wp-cli
*
* @property-read array{Name?: string}|null $plugin_info
* @property-read \WP_Theme|null $theme_info
*/
class ExtensionUpgraderSkin extends UpgraderSkin {

/**
* Called before an update is performed.
*/
public function before() {
// These properties are defined in `Bulk_Plugin_Upgrader_Skin`/`Bulk_Theme_Upgrader_Skin`
if ( isset( $this->plugin_info ) && is_array( $this->plugin_info ) && isset( $this->plugin_info['Name'] ) ) {
WP_CLI::log( sprintf( 'Updating %s...', html_entity_decode( $this->plugin_info['Name'], ENT_QUOTES, get_bloginfo( 'charset' ) ) ) );
} elseif ( isset( $this->theme_info ) && is_object( $this->theme_info ) && method_exists( $this->theme_info, 'get' ) ) {
Expand Down
4 changes: 2 additions & 2 deletions src/WP_CLI/ParseThemeNameInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ private function get_all_themes() {

if ( is_multisite() ) {
/**
* @var array<string, array{enabled: string}>} $site_enabled
* @var array<string, array{enabled: string}> $site_enabled
*/
$site_enabled = get_option( 'allowedthemes' );
if ( empty( $site_enabled ) ) {
$site_enabled = array();
}

/**
* @var array<string, array{enabled: string}>} $network_enabled
* @var array<string, array{enabled: string}> $network_enabled
*/
$network_enabled = get_site_option( 'allowedthemes' );
Comment thread
swissspidy marked this conversation as resolved.
if ( empty( $network_enabled ) ) {
Expand Down