11<?php
22
3+ use WP_CLI \CommandWithUpgrade ;
34use WP_CLI \ParsePluginNameInput ;
45use WP_CLI \Utils ;
56use WP_CLI \WpOrgApi ;
4344 * @package wp-cli
4445 *
4546 * @phpstan-type PluginInformation object{name: string, slug: non-empty-string, version: string, new_version: string, download_link: string, requires_php?: string, requires?: string, package: string}&\stdClass
47+ * @extends CommandWithUpgrade<string,>
4648 */
47- class Plugin_Command extends \WP_CLI \CommandWithUpgrade {
48-
49+ class Plugin_Command extends CommandWithUpgrade {
4950 use ParsePluginNameInput;
5051
5152 protected $ item_type = 'plugin ' ;
@@ -72,6 +73,8 @@ class Plugin_Command extends \WP_CLI\CommandWithUpgrade {
7273 * Plugin fetcher instance.
7374 *
7475 * @var \WP_CLI\Fetchers\Plugin
76+ *
77+ * @phpstan-ignore property.phpDocType (To be fixed with in https://github.com/wp-cli/wp-cli/pull/6096)
7578 */
7679 protected $ fetcher ;
7780
@@ -354,9 +357,9 @@ protected function get_all_items() {
354357 * @param array $args
355358 * @param array $assoc_args
356359 */
357- public function activate ( $ args , $ assoc_args = array () ) {
358- $ network_wide = ( bool ) Utils \get_flag_value ( $ assoc_args , 'network ' , false );
359- $ all = ( bool ) Utils \get_flag_value ( $ assoc_args , 'all ' , false );
360+ public function activate ( $ args , $ assoc_args = [] ) {
361+ $ network_wide = Utils \get_flag_value ( $ assoc_args , 'network ' , false );
362+ $ all = Utils \get_flag_value ( $ assoc_args , 'all ' , false );
360363 $ all_exclude = Utils \get_flag_value ( $ assoc_args , 'exclude ' , '' );
361364
362365 /**
@@ -453,9 +456,9 @@ public function activate( $args, $assoc_args = array() ) {
453456 * Plugin 'ninja-forms' deactivated.
454457 * Success: Deactivated 2 of 2 plugins.
455458 */
456- public function deactivate ( $ args , $ assoc_args = array () ) {
457- $ network_wide = ( bool ) Utils \get_flag_value ( $ assoc_args , 'network ' );
458- $ disable_all = ( bool ) Utils \get_flag_value ( $ assoc_args , 'all ' );
459+ public function deactivate ( $ args , $ assoc_args = [] ) {
460+ $ network_wide = Utils \get_flag_value ( $ assoc_args , 'network ' );
461+ $ disable_all = Utils \get_flag_value ( $ assoc_args , 'all ' );
459462 $ disable_all_exclude = Utils \get_flag_value ( $ assoc_args , 'exclude ' , '' );
460463
461464 /**
@@ -550,7 +553,7 @@ public function deactivate( $args, $assoc_args = array() ) {
550553 * Plugin 'akismet' activated.
551554 * Success: Toggled 1 of 1 plugins.
552555 */
553- public function toggle ( $ args , $ assoc_args = array () ) {
556+ public function toggle ( $ args , $ assoc_args ) {
554557 $ network_wide = Utils \get_flag_value ( $ assoc_args , 'network ' );
555558
556559 $ successes = 0 ;
@@ -752,7 +755,7 @@ protected function install_from_repo( $slug, $assoc_args ) {
752755 * @alias upgrade
753756 */
754757 public function update ( $ args , $ assoc_args ) {
755- $ all = ( bool ) Utils \get_flag_value ( $ assoc_args , 'all ' , false );
758+ $ all = Utils \get_flag_value ( $ assoc_args , 'all ' , false );
756759
757760 $ args = $ this ->check_optional_args_and_all ( $ args , $ all );
758761 if ( ! $ args ) {
@@ -792,10 +795,11 @@ protected function get_item_list() {
792795
793796 foreach ( $ this ->get_all_plugins () as $ file => $ details ) {
794797 $ all_update_info = $ this ->get_update_info ();
795- $ update_info = ( isset ( $ all_update_info ->response [ $ file ] ) && null !== $ all_update_info ->response [ $ file ] ) ? (array ) $ all_update_info ->response [ $ file ] : null ;
796- $ name = Utils \get_plugin_name ( $ file );
797- $ wporg_info = $ this ->get_wporg_data ( $ name );
798- $ plugin_data = get_plugin_data ( WP_PLUGIN_DIR . '/ ' . $ file , false , false );
798+ // @phpstan-ignore notIdentical.alwaysTrue
799+ $ update_info = ( isset ( $ all_update_info ->response [ $ file ] ) && null !== $ all_update_info ->response [ $ file ] ) ? (array ) $ all_update_info ->response [ $ file ] : null ;
800+ $ name = Utils \get_plugin_name ( $ file );
801+ $ wporg_info = $ this ->get_wporg_data ( $ name );
802+ $ plugin_data = get_plugin_data ( WP_PLUGIN_DIR . '/ ' . $ file , false , false );
799803
800804 if ( ! isset ( $ duplicate_names [ $ name ] ) ) {
801805 $ duplicate_names [ $ name ] = array ();
@@ -1207,8 +1211,8 @@ public function get( $args, $assoc_args ) {
12071211 * Uninstalled and deleted 'tinymce-templates' plugin.
12081212 * Success: Uninstalled 2 of 2 plugins.
12091213 */
1210- public function uninstall ( $ args , $ assoc_args = array () ) {
1211- $ all = ( bool ) Utils \get_flag_value ( $ assoc_args , 'all ' , false );
1214+ public function uninstall ( $ args , $ assoc_args = [] ) {
1215+ $ all = Utils \get_flag_value ( $ assoc_args , 'all ' , false );
12121216 $ all_exclude = Utils \get_flag_value ( $ assoc_args , 'exclude ' , false );
12131217
12141218 /**
@@ -1340,7 +1344,7 @@ public function uninstall( $args, $assoc_args = array() ) {
13401344 *
13411345 * @subcommand is-installed
13421346 */
1343- public function is_installed ( $ args , $ assoc_args = array () ) {
1347+ public function is_installed ( $ args , $ assoc_args ) {
13441348 if ( $ this ->fetcher ->get ( $ args [0 ] ) ) {
13451349 WP_CLI ::halt ( 0 );
13461350 } else {
@@ -1370,8 +1374,8 @@ public function is_installed( $args, $assoc_args = array() ) {
13701374 *
13711375 * @subcommand is-active
13721376 */
1373- public function is_active ( $ args , $ assoc_args = array () ) {
1374- $ network_wide = ( bool ) Utils \get_flag_value ( $ assoc_args , 'network ' );
1377+ public function is_active ( $ args , $ assoc_args ) {
1378+ $ network_wide = Utils \get_flag_value ( $ assoc_args , 'network ' );
13751379
13761380 $ plugin = $ this ->fetcher ->get ( $ args [0 ] );
13771381
@@ -1414,8 +1418,8 @@ public function is_active( $args, $assoc_args = array() ) {
14141418 * Deleted 'tinymce-templates' plugin.
14151419 * Success: Deleted 2 of 2 plugins.
14161420 */
1417- public function delete ( $ args , $ assoc_args = array () ) {
1418- $ all = ( bool ) Utils \get_flag_value ( $ assoc_args , 'all ' , false );
1421+ public function delete ( $ args , $ assoc_args ) {
1422+ $ all = Utils \get_flag_value ( $ assoc_args , 'all ' , false );
14191423 $ all_exclude = Utils \get_flag_value ( $ assoc_args , 'exclude ' , false );
14201424
14211425 /**
0 commit comments