Skip to content

Docs: Add missing @return tag to WP_Image_Editor_Imagick::remove_pdf_alpha_channel() - #13200

Open
csemazharul wants to merge 1 commit into
WordPress:trunkfrom
csemazharul:fix/imagick-pdf-alpha-docblock
Open

Docs: Add missing @return tag to WP_Image_Editor_Imagick::remove_pdf_alpha_channel()#13200
csemazharul wants to merge 1 commit into
WordPress:trunkfrom
csemazharul:fix/imagick-pdf-alpha-docblock

Conversation

@csemazharul

@csemazharul csemazharul commented Aug 20, 2026

Copy link
Copy Markdown

Trac ticket: https://core.trac.wordpress.org/ticket/65916

WP_Image_Editor_Imagick::remove_pdf_alpha_channel() returns a WP_Error if Imagick::setImageAlphaChannel() throws, but there's no @return tag in the DocBlock. Been like that since the method was added in changeset 56271 (Trac #39216).

/**
 * Removes PDF alpha after it's been read.
 *
 * @since 6.4.0
 */
protected function remove_pdf_alpha_channel() {
	...
	} catch ( Exception $e ) {
		return new WP_Error( 'pdf_alpha_process_failed', $e->getMessage() );
	}
}

Found it while looking at Trac #65817. PHPStan's return.missing rule didn't catch it because there's no declared return type, so it got skipped even though set_imagick_time_limit() in the same file is being fixed for that rule in #13082.

This just adds the tag. Nothing else changes, and PHPCS output for the file is the same before and after.

One other thing I ran into: the only caller, on line 372, throws the return value away, while pdf_load_source() and ->valid() right next to it are both checked. Not sure what the right call is there. Returning the error from load() would kill the PDF preview completely instead of just giving you one with a black background, which seems worse. Or the WP_Error could come out since nothing reads it. Left it alone for now, can do either if someone has a preference.

`WP_Image_Editor_Imagick::remove_pdf_alpha_channel()`, introduced in [56271],
returns a `WP_Error` object when `Imagick::setImageAlphaChannel()` throws, but
its DocBlock declares no return value.

This documents the existing return value only; no behavior is changed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props mazharul78.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant