Skip to content

Commit 075dddc

Browse files
authored
Merge pull request #498 from wp-cli/fix-phpstan
2 parents 17a5f52 + 4b13d6c commit 075dddc

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

src/Plugin_Command.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,6 +1216,10 @@ private function get_plugin_dependencies( $slug ) {
12161216
return [];
12171217
}
12181218

1219+
/**
1220+
* @var object{requires_plugins?: array} $api
1221+
*/
1222+
12191223
// Check if requires_plugins field exists and is not empty
12201224
if ( ! empty( $api->requires_plugins ) && is_array( $api->requires_plugins ) ) {
12211225
return $api->requires_plugins;

src/WP_CLI/CommandWithUpgrade.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ abstract protected function get_item_list();
8181
*/
8282
abstract protected function filter_item_list( $items, $args );
8383

84+
/**
85+
* @return array<string, array{slug: string, name: string, update: string, recently_active?: bool, status: string, version: string}>
86+
*/
8487
abstract protected function get_all_items();
8588

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

239242
$filter = function ( $source ) use ( $slug ) {
243+
/**
244+
* @var \WP_Filesystem_Base $wp_filesystem
245+
*/
246+
global $wp_filesystem;
247+
240248
/**
241249
* @var string $path
242250
*/
@@ -255,7 +263,7 @@ public function install( $args, $assoc_args ) {
255263
}
256264
$new_path = substr_replace( $source, $slug_dir, (int) strrpos( $source, $source_dir ), strlen( $source_dir ) );
257265

258-
if ( $GLOBALS['wp_filesystem']->move( $source, $new_path ) ) {
266+
if ( $wp_filesystem->move( $source, $new_path ) ) {
259267
WP_CLI::log( sprintf( "Renamed Github-based project from '%s' to '%s'.", $source_dir, $slug_dir ) );
260268
return $new_path;
261269
}
@@ -874,6 +882,9 @@ protected function _search( $args, $assoc_args ) {
874882
// In older WP versions these used to be objects.
875883
foreach ( $items as $index => $item_object ) {
876884
if ( is_array( $item_object ) ) {
885+
/**
886+
* @var array{slug: string} $item_object
887+
*/
877888
$items[ $index ]['url'] = "https://wordpress.org/{$plural}/{$item_object['slug']}/";
878889
} elseif ( $item_object instanceof \stdClass ) {
879890
$item_object->url = "https://wordpress.org/{$plural}/{$item_object->slug}/";

src/WP_CLI/ExtensionUpgraderSkin.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@
88
* An Upgrader Skin for extensions (plugins/themes) that displays which item is being updated
99
*
1010
* @package wp-cli
11+
*
12+
* @property-read array{Name?: string}|null $plugin_info
13+
* @property-read \WP_Theme|null $theme_info
1114
*/
1215
class ExtensionUpgraderSkin extends UpgraderSkin {
1316

1417
/**
1518
* Called before an update is performed.
1619
*/
1720
public function before() {
21+
// These properties are defined in `Bulk_Plugin_Upgrader_Skin`/`Bulk_Theme_Upgrader_Skin`
1822
if ( isset( $this->plugin_info ) && is_array( $this->plugin_info ) && isset( $this->plugin_info['Name'] ) ) {
1923
WP_CLI::log( sprintf( 'Updating %s...', html_entity_decode( $this->plugin_info['Name'], ENT_QUOTES, get_bloginfo( 'charset' ) ) ) );
2024
} elseif ( isset( $this->theme_info ) && is_object( $this->theme_info ) && method_exists( $this->theme_info, 'get' ) ) {

src/WP_CLI/ParseThemeNameInput.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ private function get_all_themes() {
5858

5959
if ( is_multisite() ) {
6060
/**
61-
* @var array<string, array{enabled: string}>} $site_enabled
61+
* @var array<string, array{enabled: string}> $site_enabled
6262
*/
6363
$site_enabled = get_option( 'allowedthemes' );
6464
if ( empty( $site_enabled ) ) {
6565
$site_enabled = array();
6666
}
6767

6868
/**
69-
* @var array<string, array{enabled: string}>} $network_enabled
69+
* @var array<string, array{enabled: string}> $network_enabled
7070
*/
7171
$network_enabled = get_site_option( 'allowedthemes' );
7272
if ( empty( $network_enabled ) ) {

0 commit comments

Comments
 (0)