@@ -131,19 +131,13 @@ class AI_Command extends WP_CLI_Command {
131131 public function generate ( $ args , $ assoc_args ) {
132132 list ( $ type , $ prompt ) = $ args ;
133133
134- // @phpstan-ignore function.notFound
135134 if ( ! wp_supports_ai () ) {
136135 WP_CLI ::error ( 'AI features are not supported in this environment. ' );
137136 }
138137
139138 try {
140- // @phpstan-ignore function.notFound
141139 $ builder = wp_ai_client_prompt ( $ prompt );
142140
143- if ( is_wp_error ( $ builder ) ) {
144- WP_CLI ::error ( $ builder ->get_error_message () );
145- }
146-
147141 if ( isset ( $ assoc_args ['provider ' ] ) ) {
148142 $ builder = $ builder ->using_provider ( $ assoc_args ['provider ' ] );
149143 }
@@ -231,7 +225,6 @@ public function generate( $args, $assoc_args ) {
231225 * @return void
232226 */
233227 public function is_supported ( $ args , $ assoc_args ) {
234- // @phpstan-ignore function.notFound
235228 if ( wp_supports_ai () ) {
236229 WP_CLI ::halt ( 0 );
237230 } else {
@@ -271,19 +264,13 @@ public function check( $args, $assoc_args ) {
271264 list ( $ prompt ) = $ args ;
272265 $ type = $ assoc_args ['type ' ] ?? 'text ' ;
273266
274- // @phpstan-ignore function.notFound
275267 if ( ! wp_supports_ai () ) {
276268 WP_CLI ::error ( 'AI features are not supported in this environment. ' );
277269 }
278270
279271 try {
280- // @phpstan-ignore function.notFound
281272 $ builder = wp_ai_client_prompt ( $ prompt );
282273
283- if ( is_wp_error ( $ builder ) ) {
284- WP_CLI ::error ( $ builder ->get_error_message () );
285- }
286-
287274 if ( 'text ' === $ type ) {
288275 $ supported = $ builder ->is_supported_for_text_generation ();
289276 if ( $ supported ) {
@@ -342,13 +329,8 @@ public function check( $args, $assoc_args ) {
342329 */
343330 public function status ( $ args , $ assoc_args ) {
344331 try {
345- // @phpstan-ignore function.notFound
346332 $ builder = wp_ai_client_prompt ();
347333
348- if ( is_wp_error ( $ builder ) ) {
349- WP_CLI ::error ( $ builder ->get_error_message () );
350- }
351-
352334 // Check each capability
353335 $ capabilities = array (
354336 array (
@@ -391,21 +373,17 @@ public function status( $args, $assoc_args ) {
391373 /**
392374 * Generates text from the prompt builder.
393375 *
394- * @param \WordPress\AI_Client\Builders\Prompt_Builder $builder The prompt builder.
395- * @param array{format: string} $assoc_args Associative arguments.
376+ * @param \WP_AI_Client_Prompt_Builder $builder The prompt builder.
377+ * @param array{format: string} $assoc_args Associative arguments.
396378 * @return void
397- *
398- * @phpstan-ignore class.notFound
399379 */
400380 private function generate_text ( $ builder , $ assoc_args ) {
401381 $ format = $ assoc_args ['format ' ] ?? 'text ' ;
402382
403- // @phpstan-ignore class.notFound
404383 if ( ! $ builder ->is_supported_for_text_generation () ) {
405384 WP_CLI ::error ( 'Text generation is not supported. Make sure AI provider credentials are configured. ' );
406385 }
407386
408- // @phpstan-ignore class.notFound
409387 $ text = $ builder ->generate_text_result ();
410388
411389 if ( is_wp_error ( $ text ) ) {
@@ -429,11 +407,8 @@ private function generate_text( $builder, $assoc_args ) {
429407 "Summary: \nModel used: %s (%s) \nToken usage: \nInput tokens: %s \nOutput tokens: %s \nTotal: %s \n" ,
430408 $ text ->getModelMetadata ()->getName (),
431409 $ text ->getProviderMetadata ()->getName (),
432- // @phpstan-ignore class.notFound
433410 $ token_usage [ TokenUsage::KEY_PROMPT_TOKENS ],
434- // @phpstan-ignore class.notFound
435411 $ token_usage [ TokenUsage::KEY_COMPLETION_TOKENS ],
436- // @phpstan-ignore class.notFound
437412 $ token_usage [ TokenUsage::KEY_TOTAL_TOKENS ]
438413 ),
439414 'ai '
@@ -443,14 +418,11 @@ private function generate_text( $builder, $assoc_args ) {
443418 /**
444419 * Generates an image from the prompt builder.
445420 *
446- * @param \WordPress\AI_Client\Builders\Prompt_Builder $builder The prompt builder.
421+ * @param \WP_AI_Client_Prompt_Builder $builder The prompt builder.
447422 * @param array{'destination-file': string, stdout: bool} $assoc_args Associative arguments.
448423 * @return void
449- *
450- * @phpstan-ignore class.notFound
451424 */
452425 private function generate_image ( $ builder , $ assoc_args ) {
453- // @phpstan-ignore class.notFound
454426 if ( ! $ builder ->is_supported_for_image_generation () ) {
455427 WP_CLI ::error ( 'Image generation is not supported. Make sure AI provider credentials are configured. ' );
456428 }
@@ -468,7 +440,6 @@ private function generate_image( $builder, $assoc_args ) {
468440 }
469441 }
470442
471- // @phpstan-ignore class.notFound
472443 $ image_file = $ builder ->generate_image ();
473444
474445 if ( is_wp_error ( $ image_file ) ) {
@@ -528,11 +499,9 @@ private function generate_image( $builder, $assoc_args ) {
528499 *
529500 * Accepts a local file path, a URL (http/https), a data URI, or a WordPress attachment ID.
530501 *
531- * @param \WordPress\AI_Client\Builders\Prompt_Builder $builder The prompt builder.
532- * @param string $image_input Local file path, URL, data URI, or attachment ID.
533- * @return mixed The updated prompt builder.
534- *
535- * @phpstan-ignore class.notFound
502+ * @param \WP_AI_Client_Prompt_Builder $builder The prompt builder.
503+ * @param string $image_input Local file path, URL, data URI, or attachment ID.
504+ * @return \WP_AI_Client_Prompt_Builder The updated prompt builder.
536505 */
537506 private function with_image_input ( $ builder , $ image_input ) {
538507 // Attachment ID (positive integer string).
@@ -546,7 +515,6 @@ private function with_image_input( $builder, $image_input ) {
546515 0 === strpos ( $ image_input , 'http:// ' ) ||
547516 0 === strpos ( $ image_input , 'https:// ' )
548517 ) {
549- // @phpstan-ignore class.notFound
550518 return $ builder ->with_file ( $ image_input );
551519 }
552520
@@ -557,11 +525,9 @@ private function with_image_input( $builder, $image_input ) {
557525 /**
558526 * Adds a WordPress attachment as image input to the prompt builder.
559527 *
560- * @param \WordPress\AI_Client\Builders\Prompt_Builder $builder The prompt builder.
561- * @param int $attachment_id The attachment ID.
562- * @return mixed The updated prompt builder.
563- *
564- * @phpstan-ignore class.notFound
528+ * @param \WP_AI_Client_Prompt_Builder $builder The prompt builder.
529+ * @param int $attachment_id The attachment ID.
530+ * @return \WP_AI_Client_Prompt_Builder The updated prompt builder.
565531 */
566532 private function with_attachment_input ( $ builder , $ attachment_id ) {
567533 $ attachment = get_post ( $ attachment_id );
@@ -595,14 +561,12 @@ private function with_attachment_input( $builder, $attachment_id ) {
595561 // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
596562 $ data_uri = 'data: ' . $ mime_type . ';base64, ' . base64_encode ( $ contents );
597563
598- // @phpstan-ignore class.notFound
599564 return $ builder ->with_file ( $ data_uri );
600565 }
601566
602567 // Fall back to the attachment URL.
603568 $ image_src = wp_get_attachment_image_src ( $ attachment_id , 'full ' );
604569 if ( $ image_src && ! empty ( $ image_src [0 ] ) ) {
605- // @phpstan-ignore class.notFound
606570 return $ builder ->with_file ( $ image_src [0 ] );
607571 }
608572
@@ -612,11 +576,9 @@ private function with_attachment_input( $builder, $attachment_id ) {
612576 /**
613577 * Adds a local image file as input to the prompt builder.
614578 *
615- * @param \WordPress\AI_Client\Builders\Prompt_Builder $builder The prompt builder.
616- * @param string $file_path The local file path.
617- * @return mixed The updated prompt builder.
618- *
619- * @phpstan-ignore class.notFound
579+ * @param \WP_AI_Client_Prompt_Builder $builder The prompt builder.
580+ * @param string $file_path The local file path.
581+ * @return \WP_AI_Client_Prompt_Builder The updated prompt builder.
620582 */
621583 private function with_local_file_input ( $ builder , $ file_path ) {
622584 if ( ! file_exists ( $ file_path ) ) {
@@ -638,7 +600,6 @@ private function with_local_file_input( $builder, $file_path ) {
638600 // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
639601 $ data_uri = 'data: ' . $ mime_type . ';base64, ' . base64_encode ( $ contents );
640602
641- // @phpstan-ignore class.notFound
642603 return $ builder ->with_file ( $ data_uri );
643604 }
644605}
0 commit comments