Skip to content

Theme JSON Resolver: Document cached static properties as nullable - #86111

Merged
westonruter merged 2 commits into
WordPress:trunkfrom
noruzzamans:fix/phpstan-theme-json-resolver-nullable-properties
Nov 3, 2026
Merged

westonruter merged 2 commits into
WordPress:trunkfrom
noruzzamans:fix/phpstan-theme-json-resolver-nullable-properties

Conversation

@noruzzamans

Copy link
Copy Markdown
Member

What?

See #86088

Documents cached static properties on WP_Theme_JSON_Resolver_Gutenberg as nullable in their @var docblocks, and removes the resolved entries from the PHPStan baseline.

Why?

The static properties $core, $blocks, $theme, $user, $user_custom_post_type_id, and $i18n_schema are all initialized to null and reset to null in clean_cached_data(). Because their @var docblocks documented them without |null, PHPStan reported assign.propertyType errors when they are reset. This resolves 6 of the 226 errors initially baselined in #66693.

How?

  • In lib/class-wp-theme-json-resolver-gutenberg.php, added |null to the @var tags for $core, $blocks, $theme, $user, $user_custom_post_type_id, and $i18n_schema.
  • Removed the 6 corresponding entries from tools/phpstan/baseline.neon.

There is no runtime logic change, only docblock corrections.

Testing Instructions

  1. Run composer phpstan and confirm it passes with no 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.

@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: noruzzamans <noruzzaman@git.wordpress.org>
Co-authored-by: huzaifaalmesbah <huzaifaalmesbah@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 [Type] Code Quality Issues or PRs that relate to code quality No Core Sync Required Indicates that any changes do not need to be synced to WordPress Core labels Nov 1, 2026
@huzaifaalmesbah

Copy link
Copy Markdown
Member

Looks good. Core's WP_Theme_JSON_Resolver has the same @var tags without |null, and Core's PHPStan baseline still carries the same 6 assign.propertyType entries, so it might be worth opening a matching Core PR so they don't drift apart.

@westonruter westonruter left a comment

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.

I've opened WordPress/wordpress-develop#15385 to apply the same fixes to core.

@westonruter
westonruter merged commit f21d078 into WordPress:trunk Nov 3, 2026
80 checks passed
@github-actions github-actions Bot added this to the Gutenberg 24.4 milestone Nov 3, 2026
wporg-sync pushed a commit to WordPress/wordpress-develop that referenced this pull request Nov 3, 2026
The cached static properties of `WP_Theme_JSON_Resolver` all default to `null` and are reset to `null` in `clean_cached_data()`, and the getters check them against `null` to decide whether to rebuild the cache, but their `@var` tags omitted `null`. Adding it removes the six resulting `assign.propertyType` entries from the PHPStan baseline. There is no runtime change.

This mirrors the same fix to `WP_Theme_JSON_Resolver_Gutenberg` in the Gutenberg plugin, developed in WordPress/gutenberg#86111.

Developed in #15385.
Follow-up to r50959, r52049, r54493, r63022.

Props noruzzaman, huzaifaalmesbah.
See #65817.


git-svn-id: https://develop.svn.wordpress.org/trunk@65218 602fd350-edb4-49c9-b593-d223f7449a82
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Nov 3, 2026
The cached static properties of `WP_Theme_JSON_Resolver` all default to `null` and are reset to `null` in `clean_cached_data()`, and the getters check them against `null` to decide whether to rebuild the cache, but their `@var` tags omitted `null`. Adding it removes the six resulting `assign.propertyType` entries from the PHPStan baseline. There is no runtime change.

This mirrors the same fix to `WP_Theme_JSON_Resolver_Gutenberg` in the Gutenberg plugin, developed in WordPress/gutenberg#86111.

Developed in WordPress/wordpress-develop#15385.
Follow-up to r50959, r52049, r54493, r63022.

Props noruzzaman, huzaifaalmesbah.
See #65817.

Built from https://develop.svn.wordpress.org/trunk@65218


git-svn-id: http://core.svn.wordpress.org/trunk@64367 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@ingeniumed ingeniumed added the Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json label Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json No Core Sync Required Indicates that any changes do not need to be synced to WordPress Core [Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants