@@ -38,8 +38,19 @@ abstract class Command
3838 */
3939 protected static bool $ allow_all_sites_flag = false ;
4040
41+ /**
42+ * The site query for those commands that allow the --all-sites flag
43+ *
44+ * @see https://developer.wordpress.org/reference/functions/get_sites/
45+ *
46+ * @var array<string,mixed>
47+ */
48+ protected static array $ site_query = ['deleted ' => 0 , 'number ' => PHP_INT_MAX ];
49+
4150 /**
4251 * Synopsis of the command
52+ *
53+ * @var array<int,array<string|mixed>>
4354 */
4455 protected static array $ synopsis = [];
4556
@@ -55,10 +66,19 @@ abstract class Command
5566
5667 /**
5768 * All subclasses must have an invoke method that handles the command
69+ *
70+ * @param array<mixed> $args
71+ * @param array<string,mixed> $assoc_args
5872 */
59- abstract protected static function invoke ( array $ args , array $ assoc_args );
73+ abstract protected static function invoke ( array $ args , array $ assoc_args ): void ;
6074
61- public function __invoke ( array $ args , array $ assoc_args )
75+ /**
76+ * Actual handler of the command
77+ *
78+ * @param array<mixed> $args
79+ * @param array<string,mixed> $assoc_args
80+ */
81+ public function __invoke ( array $ args , array $ assoc_args ): void
6282 {
6383 if ( ! is_multisite () ) {
6484 static ::invoke ( $ args , $ assoc_args );
@@ -69,8 +89,11 @@ public function __invoke( array $args, array $assoc_args )
6989
7090 /**
7191 * Handle the command for multisite installations
92+ *
93+ * @param array<mixed> $args
94+ * @param array<string,mixed> $assoc_args
7295 */
73- public static function invoke_multisite ( array $ args , array $ assoc_args )
96+ public static function invoke_multisite ( array $ args , array $ assoc_args ): void
7497 {
7598 $ all_sites_flag = Utils::get_flag_value ( $ assoc_args , 'all-sites ' );
7699
@@ -81,7 +104,7 @@ public static function invoke_multisite( array $args, array $assoc_args )
81104
82105 // If the --all-sites flag is set then run the handler on all sites.
83106 if ( $ all_sites_flag ) {
84- Utils::run_on_all_sites ( [ static ::class, 'invoke ' ], $ args , $ assoc_args );
107+ Utils::run_on_all_sites ( [ static ::class, 'invoke ' ], $ args , $ assoc_args, static :: $ site_query );
85108 } else {
86109 // Run the handler on the current site.
87110 static ::invoke ( $ args , $ assoc_args );
@@ -238,7 +261,7 @@ public static function _after_invoke(): void
238261 /**
239262 * Get the command synopsis
240263 *
241- * @return array[]
264+ * @return array<int,array<string|mixed>>
242265 */
243266 public static function get_synopsis (): array
244267 {
0 commit comments