From 76b258bcc38c7016d6aa472b35b6e812709b9aac Mon Sep 17 00:00:00 2001 From: peptiderepo Date: Thu, 16 Apr 2026 17:05:12 +0700 Subject: [PATCH] fix: remove union return types for PHP 7.4 compatibility Union types (array|WP_Error, int|WP_Error, string|WP_Error) require PHP 8.0+. Removed return type declarations while keeping @return docblocks intact for IDE/static analysis support. Co-Authored-By: Claude Opus 4.6 --- includes/core/class-image-media-sideloader.php | 4 ++-- includes/core/class-image-pipeline.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/core/class-image-media-sideloader.php b/includes/core/class-image-media-sideloader.php index 2128067..e007cfc 100644 --- a/includes/core/class-image-media-sideloader.php +++ b/includes/core/class-image-media-sideloader.php @@ -38,7 +38,7 @@ class PRAutoBlogger_Image_Media_Sideloader { * * @return int|\WP_Error Attachment ID on success, WP_Error on failure. */ - public function sideload_image( array $image_data, int $post_id, string $alt_text = '' ): int | \WP_Error { + public function sideload_image( array $image_data, int $post_id, string $alt_text = '' ) { // Validate input. if ( empty( $image_data['bytes'] ) ) { return new \WP_Error( 'invalid_image_data', 'Image data (bytes) is empty.' ); @@ -97,7 +97,7 @@ class PRAutoBlogger_Image_Media_Sideloader { * * @return string|\WP_Error Path to temporary file on success, WP_Error on failure. */ - private function create_temp_file( string $bytes, string $mime_type ): string | \WP_Error { + private function create_temp_file( string $bytes, string $mime_type ) { $temp_dir = get_temp_dir(); $filename = 'prautoblogger_img_' . wp_generate_uuid4() . $this->get_extension_for_mime( $mime_type ); $temp_path = $temp_dir . $filename; diff --git a/includes/core/class-image-pipeline.php b/includes/core/class-image-pipeline.php index 713aa85..1cdb085 100644 --- a/includes/core/class-image-pipeline.php +++ b/includes/core/class-image-pipeline.php @@ -153,7 +153,7 @@ class PRAutoBlogger_Image_Pipeline { * cost_usd: float, * }|\WP_Error */ - private function generate_image_a( int $post_id, array $article_data ): array | \WP_Error { + private function generate_image_a( int $post_id, array $article_data ) { try { // Build the article-driven prompt. $prompt = $this->prompt_builder->build_article_prompt( $article_data ); @@ -219,7 +219,7 @@ class PRAutoBlogger_Image_Pipeline { * cost_usd: float, * }|\WP_Error */ - private function generate_image_b( int $post_id, array $source_data ): array | \WP_Error { + private function generate_image_b( int $post_id, array $source_data ) { try { // Build the source-driven prompt. $prompt = $this->prompt_builder->build_source_prompt( $source_data );