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 <noreply@anthropic.com>
This commit is contained in:
@@ -38,7 +38,7 @@ class PRAutoBlogger_Image_Media_Sideloader {
|
|||||||
*
|
*
|
||||||
* @return int|\WP_Error Attachment ID on success, WP_Error on failure.
|
* @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.
|
// Validate input.
|
||||||
if ( empty( $image_data['bytes'] ) ) {
|
if ( empty( $image_data['bytes'] ) ) {
|
||||||
return new \WP_Error( 'invalid_image_data', 'Image data (bytes) is empty.' );
|
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.
|
* @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();
|
$temp_dir = get_temp_dir();
|
||||||
$filename = 'prautoblogger_img_' . wp_generate_uuid4() . $this->get_extension_for_mime( $mime_type );
|
$filename = 'prautoblogger_img_' . wp_generate_uuid4() . $this->get_extension_for_mime( $mime_type );
|
||||||
$temp_path = $temp_dir . $filename;
|
$temp_path = $temp_dir . $filename;
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ class PRAutoBlogger_Image_Pipeline {
|
|||||||
* cost_usd: float,
|
* cost_usd: float,
|
||||||
* }|\WP_Error
|
* }|\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 {
|
try {
|
||||||
// Build the article-driven prompt.
|
// Build the article-driven prompt.
|
||||||
$prompt = $this->prompt_builder->build_article_prompt( $article_data );
|
$prompt = $this->prompt_builder->build_article_prompt( $article_data );
|
||||||
@@ -219,7 +219,7 @@ class PRAutoBlogger_Image_Pipeline {
|
|||||||
* cost_usd: float,
|
* cost_usd: float,
|
||||||
* }|\WP_Error
|
* }|\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 {
|
try {
|
||||||
// Build the source-driven prompt.
|
// Build the source-driven prompt.
|
||||||
$prompt = $this->prompt_builder->build_source_prompt( $source_data );
|
$prompt = $this->prompt_builder->build_source_prompt( $source_data );
|
||||||
|
|||||||
Reference in New Issue
Block a user