Skip to content

Fix invalid PHPDoc tags reported by PHPStan - #86092

Merged
westonruter merged 2 commits into
WordPress:trunkfrom
huzaifaalmesbah:fix/phpstan-phpdoc-errors
Nov 1, 2026
Merged

westonruter merged 2 commits into
WordPress:trunkfrom
huzaifaalmesbah:fix/phpstan-phpdoc-errors

Conversation

@huzaifaalmesbah

@huzaifaalmesbah huzaifaalmesbah commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

What?

See #86088

Fixes invalid PHPDoc tags reported by PHPStan in four block registration functions and in WP_Style_Engine, and removes the resolved entries from the PHPStan baseline.

Why?

PHPStan reports these docblocks as invalid, so the documented types are either wrong or ignored entirely. Together, these changes clear 6 of the 226 errors initially baselined in #66693 (all throws.notThrowable and phpDoc.parseError errors).

How?

  • Removed @throws WP_Error from register_block_core_home_link(), register_block_core_navigation(), register_block_core_navigation_link(), and register_block_core_navigation_submenu(). WP_Error is not a Throwable, and register_block_type_from_metadata() returns false on failure rather than throwing. No other block registration function documents a @throws tag.
  • In WP_Style_Engine, changed @param string? $style_value to @param string $style_value in is_valid_style_value(), and removed the @return void. tag from store_css_rule(). Both now match the docblocks in WordPress Core's copy of the class.
  • Removed the 6 corresponding entries from tools/phpstan/baseline.neon.

Docblock changes only; there is no change in behavior.

Testing Instructions

  1. Run composer phpstan and confirm it passes with no unmatched ignored errors.
  2. Run composer phpstan:baselines and confirm tools/phpstan/baseline.neon has no further changes.

Testing Instructions for Keyboard

Not applicable. There are no UI changes.

Screenshots or screencast

Not applicable.

Use of AI Tools

I used Claude Code to identify the affected occurrences and draft the change. I reviewed the diff and take responsibility for it.

Remove the `@throws WP_Error` tags from the Home Link, Navigation, Navigation Link, and Navigation Submenu block registration functions: `WP_Error` is not an exception, and `register_block_type_from_metadata()` does not throw. Fix the unparsable `@param string?` and `@return void.` tags in `WP_Style_Engine` to match WordPress Core. Remove the 6 resolved entries from the PHPStan baseline.

See WordPress#86088.
@huzaifaalmesbah huzaifaalmesbah added the [Type] Code Quality Issues or PRs that relate to code quality label Nov 1, 2026
@github-actions github-actions Bot added [Package] Block library /packages/block-library [Package] Style Engine /packages/style-engine labels Nov 1, 2026
@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: huzaifaalmesbah <huzaifaalmesbah@git.wordpress.org>
Co-authored-by: westonruter <westonruter@git.wordpress.org>

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


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

@huzaifaalmesbah huzaifaalmesbah added the No Core Sync Required Indicates that any changes do not need to be synced to WordPress Core label Nov 1, 2026
@huzaifaalmesbah
huzaifaalmesbah marked this pull request as ready for review November 1, 2026 01:52
* Util: Checks whether an incoming block style value is valid.
*
* @param string? $style_value A single css preset value.
* @param string $style_value A single CSS preset value.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@westonruter
westonruter merged commit dec5dbc into WordPress:trunk Nov 1, 2026
76 checks passed
@github-actions github-actions Bot added this to the Gutenberg 24.4 milestone Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

No Core Sync Required Indicates that any changes do not need to be synced to WordPress Core [Package] Block library /packages/block-library [Package] Style Engine /packages/style-engine [Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants