@@ -93,6 +93,7 @@ class Term_Command extends WP_CLI_Command {
9393 *
9494 * These fields are optionally available:
9595 *
96+ * * term_group
9697 * * url
9798 *
9899 * ## EXAMPLES
@@ -139,9 +140,6 @@ public function list_( $args, $assoc_args ) {
139140 $ term = get_term_by ( 'id ' , $ assoc_args ['term_id ' ], $ args [0 ] );
140141 $ terms = [ $ term ];
141142 } else {
142- /**
143- * @var \WP_Term[] $terms
144- */
145143 $ terms = get_terms (
146144 array_merge (
147145 $ assoc_args ,
@@ -150,6 +148,15 @@ public function list_( $args, $assoc_args ) {
150148 ]
151149 )
152150 );
151+
152+ // This should never happen because of the taxonomy_exists check above.
153+ if ( is_wp_error ( $ terms ) ) {
154+ WP_CLI ::error ( $ terms );
155+ }
156+
157+ /**
158+ * @var \WP_Term[] $terms
159+ */
153160 }
154161
155162 $ terms = array_map (
@@ -294,6 +301,7 @@ public function get( $args, $assoc_args ) {
294301 WP_CLI ::error ( "Term doesn't exist. " );
295302 }
296303
304+ // @phpstan-ignore property.notFound
297305 if ( ! isset ( $ term ->url ) ) {
298306 // @phpstan-ignore property.notFound
299307 $ term ->url = get_term_link ( $ term );
@@ -648,18 +656,23 @@ public function recount( $args ) {
648656 if ( ! taxonomy_exists ( $ taxonomy ) ) {
649657 WP_CLI ::warning ( "Taxonomy {$ taxonomy } does not exist. " );
650658 } else {
651-
652- /**
653- * @var \WP_Term[] $terms
654- */
655-
656659 $ terms = get_terms (
657660 [
658661 'taxonomy ' => $ taxonomy ,
659662 'hide_empty ' => false ,
660663 ]
661664 );
662665
666+ // This should never happen because of the taxonomy_exists check above.
667+ if ( is_wp_error ( $ terms ) ) {
668+ WP_CLI ::warning ( "Taxonomy {$ taxonomy } does not exist. " );
669+ continue ;
670+ }
671+
672+ /**
673+ * @var \WP_Term[] $terms
674+ */
675+
663676 $ term_taxonomy_ids = wp_list_pluck ( $ terms , 'term_taxonomy_id ' );
664677
665678 wp_update_term_count ( $ term_taxonomy_ids , $ taxonomy );
0 commit comments