@@ -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 }
@@ -356,8 +372,12 @@ public function hook( $args, $assoc_args ) {
356372 * +-----------+----------------------------+----------+---------+
357373 * | total (2) | | | 0.3994s |
358374 * +-----------+----------------------------+----------+---------+
359- *
375+ * @skipglobalargcheck
360376 * @when before_wp_load
377+ *
378+ * @param array<string> $args Positional arguments. Unused.
379+ * @param array{url?: string, fields?: string, format: string, order: string, orderby?: string} $assoc_args Associative arguments.
380+ * @return void
361381 */
362382 public function requests ( $ args , $ assoc_args ) {
363383 $ order = Utils \get_flag_value ( $ assoc_args , 'order ' , 'ASC ' );
@@ -429,13 +449,19 @@ public function requests( $args, $assoc_args ) {
429449 * | 0.1009s | 100% | 1 |
430450 * +---------+-------------+---------------+
431451 *
452+ * @param array{0: string} $args Positional arguments.
453+ * @param array{hook?: bool|string, fields: string, format: string, order: string, orderby?: string} $assoc_args Associative arguments.
454+ * @return void
455+ *
432456 * @subcommand eval
433457 */
434458 public function eval_ ( $ args , $ assoc_args ) {
435459 $ statement = $ args [0 ];
436460
437- $ order = Utils \get_flag_value ( $ assoc_args , 'order ' , 'ASC ' );
438- $ 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 ;
439465
440466 self ::profile_eval_ish (
441467 $ assoc_args ,
@@ -498,14 +524,20 @@ function () use ( $statement ) {
498524 * | 0.1009s | 100% | 1 |
499525 * +---------+-------------+---------------+
500526 *
527+ * @param array{0: string} $args Positional arguments.
528+ * @param array{hook?: string|bool, fields?: string, format: string, order: string, orderby?: string} $assoc_args Associative arguments.
529+ * @return void
530+ *
501531 * @subcommand eval-file
502532 */
503533 public function eval_file ( $ args , $ assoc_args ) {
504534
505535 $ file = $ args [0 ];
506536
507- $ order = Utils \get_flag_value ( $ assoc_args , 'order ' , 'ASC ' );
508- $ orderby = Utils \get_flag_value ( $ assoc_args , 'orderby ' , null );
537+ $ order_val = Utils \get_flag_value ( $ assoc_args , 'order ' , 'ASC ' );
538+ $ order = is_string ( $ order_val ) ? $ order_val : 'ASC ' ;
539+ $ orderby_val = Utils \get_flag_value ( $ assoc_args , 'orderby ' , null );
540+ $ orderby = ( is_string ( $ orderby_val ) || is_null ( $ orderby_val ) ) ? $ orderby_val : null ;
509541
510542 if ( ! file_exists ( $ file ) ) {
511543 WP_CLI ::error ( "' $ file' does not exist. " );
@@ -523,6 +555,12 @@ function () use ( $file ) {
523555
524556 /**
525557 * Profile an eval or eval-file statement.
558+ *
559+ * @param array{hook?: string|bool} $assoc_args
560+ * @param callable $profile_callback
561+ * @param string $order
562+ * @param string|null $orderby
563+ * @return void
526564 */
527565 private static function profile_eval_ish ( $ assoc_args , $ profile_callback , $ order = 'ASC ' , $ orderby = null ) {
528566 $ hook = Utils \get_flag_value ( $ assoc_args , 'hook ' );
@@ -572,6 +610,7 @@ private static function profile_eval_ish( $assoc_args, $profile_callback, $order
572610 * Include a file without exposing it to current scope
573611 *
574612 * @param string $file
613+ * @return void
575614 */
576615 private static function include_file ( $ file ) {
577616 include $ file ;
@@ -580,9 +619,9 @@ private static function include_file( $file ) {
580619 /**
581620 * Filter loggers with zero-ish values.
582621 *
583- * @param array $loggers
584- * @param array $metrics
585- * @return array
622+ * @param array<\WP_CLI\Profile\Logger> $loggers
623+ * @param array<string> $metrics
624+ * @return array<\WP_CLI\Profile\Logger>
586625 */
587626 private static function shine_spotlight ( $ loggers , $ metrics ) {
588627
@@ -622,9 +661,9 @@ private static function shine_spotlight( $loggers, $metrics ) {
622661 /**
623662 * Filter loggers to only those whose callback name matches a pattern.
624663 *
625- * @param array $loggers
626- * @param string $pattern
627- * @return array
664+ * @param array<\WP_CLI\Profile\Logger> $loggers
665+ * @param string $pattern
666+ * @return array<\WP_CLI\Profile\Logger>
628667 */
629668 private static function filter_by_callback ( $ loggers , $ pattern ) {
630669 return array_filter (
0 commit comments