@@ -140,9 +140,6 @@ public function list_( $args, $assoc_args ) {
140140 $ term = get_term_by ( 'id ' , $ assoc_args ['term_id ' ], $ args [0 ] );
141141 $ terms = [ $ term ];
142142 } else {
143- /**
144- * @var \WP_Term[] $terms
145- */
146143 $ terms = get_terms (
147144 array_merge (
148145 $ assoc_args ,
@@ -151,6 +148,15 @@ public function list_( $args, $assoc_args ) {
151148 ]
152149 )
153150 );
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+ */
154160 }
155161
156162 $ terms = array_map (
@@ -295,6 +301,7 @@ public function get( $args, $assoc_args ) {
295301 WP_CLI ::error ( "Term doesn't exist. " );
296302 }
297303
304+ // @phpstan-ignore property.notFound
298305 if ( ! isset ( $ term ->url ) ) {
299306 // @phpstan-ignore property.notFound
300307 $ term ->url = get_term_link ( $ term );
@@ -649,18 +656,23 @@ public function recount( $args ) {
649656 if ( ! taxonomy_exists ( $ taxonomy ) ) {
650657 WP_CLI ::warning ( "Taxonomy {$ taxonomy } does not exist. " );
651658 } else {
652-
653- /**
654- * @var \WP_Term[] $terms
655- */
656-
657659 $ terms = get_terms (
658660 [
659661 'taxonomy ' => $ taxonomy ,
660662 'hide_empty ' => false ,
661663 ]
662664 );
663665
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+
664676 $ term_taxonomy_ids = wp_list_pluck ( $ terms , 'term_taxonomy_id ' );
665677
666678 wp_update_term_count ( $ term_taxonomy_ids , $ taxonomy );
0 commit comments