@@ -129,14 +129,20 @@ class Command {
129129 *
130130 * @skipglobalargcheck
131131 * @when before_wp_load
132+ *
133+ * @param array{0?: string} $args Positional arguments.
134+ * @param array{all?: bool, spotlight?: bool, url?: string, fields?: string, format: string, order: string, orderby?: string} $assoc_args Associative arguments.
135+ * @return void
132136 */
133137 public function stage ( $ args , $ assoc_args ) {
134138 global $ wpdb ;
135139
136140 $ focus = Utils \get_flag_value ( $ assoc_args , 'all ' , isset ( $ args [0 ] ) ? $ args [0 ] : null );
137141
138- $ order = Utils \get_flag_value ( $ assoc_args , 'order ' , 'ASC ' );
139- $ orderby = Utils \get_flag_value ( $ assoc_args , 'orderby ' , null );
142+ $ order_val = Utils \get_flag_value ( $ assoc_args , 'order ' , 'ASC ' );
143+ $ order = is_string ( $ order_val ) ? $ order_val : 'ASC ' ;
144+ $ orderby_val = Utils \get_flag_value ( $ assoc_args , 'orderby ' , null );
145+ $ orderby = ( is_string ( $ orderby_val ) || is_null ( $ orderby_val ) ) ? $ orderby_val : null ;
140146
141147 $ valid_stages = array ( 'bootstrap ' , 'main_query ' , 'template ' );
142148 if ( $ focus && ( true !== $ focus && ! in_array ( $ focus , $ valid_stages , true ) ) ) {
@@ -181,6 +187,7 @@ public function stage( $args, $assoc_args ) {
181187 $ fields = array_merge ( $ base , $ metrics );
182188 $ formatter = new Formatter ( $ assoc_args , $ fields );
183189 $ loggers = $ profiler ->get_loggers ();
190+ /** @var array<string, bool|string> $assoc_args */
184191 if ( Utils \get_flag_value ( $ assoc_args , 'spotlight ' ) ) {
185192 $ loggers = self ::shine_spotlight ( $ loggers , $ metrics );
186193 }
@@ -257,13 +264,19 @@ public function stage( $args, $assoc_args ) {
257264 *
258265 * @skipglobalargcheck
259266 * @when before_wp_load
267+ *
268+ * @param array{0?: string} $args Positional arguments.
269+ * @param array{all?: bool, spotlight?: bool, url?: string, fields?: string, format: string, order: string, orderby?: string} $assoc_args
270+ * @return void
260271 */
261272 public function hook ( $ args , $ assoc_args ) {
262273
263274 $ focus = Utils \get_flag_value ( $ assoc_args , 'all ' , isset ( $ args [0 ] ) ? $ args [0 ] : null );
264275
265- $ order = Utils \get_flag_value ( $ assoc_args , 'order ' , 'ASC ' );
266- $ orderby = Utils \get_flag_value ( $ assoc_args , 'orderby ' , null );
276+ $ order_val = Utils \get_flag_value ( $ assoc_args , 'order ' , 'ASC ' );
277+ $ order = is_string ( $ order_val ) ? $ order_val : 'ASC ' ;
278+ $ orderby_val = Utils \get_flag_value ( $ assoc_args , 'orderby ' , null );
279+ $ orderby = ( is_string ( $ orderby_val ) || is_null ( $ orderby_val ) ) ? $ orderby_val : null ;
267280
268281 $ profiler = new Profiler ( 'hook ' , $ focus );
269282 $ profiler ->run ();
@@ -293,11 +306,14 @@ public function hook( $args, $assoc_args ) {
293306 $ fields = array_merge ( $ base , $ metrics );
294307 $ formatter = new Formatter ( $ assoc_args , $ fields );
295308 $ loggers = $ profiler ->get_loggers ();
309+ /** @var array<string, bool|string> $assoc_args */
296310 if ( Utils \get_flag_value ( $ assoc_args , 'spotlight ' ) ) {
297311 $ loggers = self ::shine_spotlight ( $ loggers , $ metrics );
298312 }
299- $ search = Utils \get_flag_value ( $ assoc_args , 'search ' , false );
300- if ( false !== $ search && '' !== $ search ) {
313+ /** @var array<string, bool|string> $assoc_args */
314+ $ search_val = Utils \get_flag_value ( $ assoc_args , 'search ' , '' );
315+ $ search = is_string ( $ search_val ) ? $ search_val : '' ;
316+ if ( '' !== $ search ) {
301317 if ( ! $ focus ) {
302318 WP_CLI ::error ( '--search requires --all or a specific hook. ' );
303319 }
@@ -357,13 +373,19 @@ public function hook( $args, $assoc_args ) {
357373 * | 0.1009s | 100% | 1 |
358374 * +---------+-------------+---------------+
359375 *
376+ * @param array{0: string} $args Positional arguments.
377+ * @param array{hook?: bool|string, fields: string, format: string, order: string, orderby?: string} $assoc_args Associative arguments.
378+ * @return void
379+ *
360380 * @subcommand eval
361381 */
362382 public function eval_ ( $ args , $ assoc_args ) {
363383 $ statement = $ args [0 ];
364384
365- $ order = Utils \get_flag_value ( $ assoc_args , 'order ' , 'ASC ' );
366- $ orderby = Utils \get_flag_value ( $ assoc_args , 'orderby ' , null );
385+ $ order_val = Utils \get_flag_value ( $ assoc_args , 'order ' , 'ASC ' );
386+ $ order = is_string ( $ order_val ) ? $ order_val : 'ASC ' ;
387+ $ orderby_val = Utils \get_flag_value ( $ assoc_args , 'orderby ' , null );
388+ $ orderby = ( is_string ( $ orderby_val ) || is_null ( $ orderby_val ) ) ? $ orderby_val : null ;
367389
368390 self ::profile_eval_ish (
369391 $ assoc_args ,
@@ -426,14 +448,20 @@ function () use ( $statement ) {
426448 * | 0.1009s | 100% | 1 |
427449 * +---------+-------------+---------------+
428450 *
451+ * @param array{0: string} $args Positional arguments.
452+ * @param array{hook?: string|bool, fields?: string, format: string, order: string, orderby?: string} $assoc_args Associative arguments.
453+ * @return void
454+ *
429455 * @subcommand eval-file
430456 */
431457 public function eval_file ( $ args , $ assoc_args ) {
432458
433459 $ file = $ args [0 ];
434460
435- $ order = Utils \get_flag_value ( $ assoc_args , 'order ' , 'ASC ' );
436- $ orderby = Utils \get_flag_value ( $ assoc_args , 'orderby ' , null );
461+ $ order_val = Utils \get_flag_value ( $ assoc_args , 'order ' , 'ASC ' );
462+ $ order = is_string ( $ order_val ) ? $ order_val : 'ASC ' ;
463+ $ orderby_val = Utils \get_flag_value ( $ assoc_args , 'orderby ' , null );
464+ $ orderby = ( is_string ( $ orderby_val ) || is_null ( $ orderby_val ) ) ? $ orderby_val : null ;
437465
438466 if ( ! file_exists ( $ file ) ) {
439467 WP_CLI ::error ( "' $ file' does not exist. " );
@@ -451,6 +479,12 @@ function () use ( $file ) {
451479
452480 /**
453481 * Profile an eval or eval-file statement.
482+ *
483+ * @param array{hook?: string|bool} $assoc_args
484+ * @param callable $profile_callback
485+ * @param string $order
486+ * @param string|null $orderby
487+ * @return void
454488 */
455489 private static function profile_eval_ish ( $ assoc_args , $ profile_callback , $ order = 'ASC ' , $ orderby = null ) {
456490 $ hook = Utils \get_flag_value ( $ assoc_args , 'hook ' );
@@ -500,6 +534,7 @@ private static function profile_eval_ish( $assoc_args, $profile_callback, $order
500534 * Include a file without exposing it to current scope
501535 *
502536 * @param string $file
537+ * @return void
503538 */
504539 private static function include_file ( $ file ) {
505540 include $ file ;
@@ -508,9 +543,9 @@ private static function include_file( $file ) {
508543 /**
509544 * Filter loggers with zero-ish values.
510545 *
511- * @param array $loggers
512- * @param array $metrics
513- * @return array
546+ * @param array<\WP_CLI\Profile\Logger> $loggers
547+ * @param array<string> $metrics
548+ * @return array<\WP_CLI\Profile\Logger>
514549 */
515550 private static function shine_spotlight ( $ loggers , $ metrics ) {
516551
@@ -550,9 +585,9 @@ private static function shine_spotlight( $loggers, $metrics ) {
550585 /**
551586 * Filter loggers to only those whose callback name matches a pattern.
552587 *
553- * @param array $loggers
554- * @param string $pattern
555- * @return array
588+ * @param array<\WP_CLI\Profile\Logger> $loggers
589+ * @param string $pattern
590+ * @return array<\WP_CLI\Profile\Logger>
556591 */
557592 private static function filter_by_callback ( $ loggers , $ pattern ) {
558593 return array_filter (
0 commit comments