Repository navigation
Theme JSON: Use self:: to call private static methods - #86096
Merged
westonruter merged 1 commit intoNov 1, 2026
Merged
westonruter merged 1 commit into
westonruter merged 1 commit into
Conversation
`WP_Theme_JSON_Gutenberg` and `WP_Theme_JSON_Resolver_Gutenberg` called their private static methods through `static::`, which PHPStan reports as unsafe since a subclass cannot see private members. Use `self::` instead, which is behavior-identical. `static::` is kept where it targets protected or public methods. This syncs the changes from WordPress Core r63368 and r63384. Remove the 37 resolved entries from the PHPStan baseline. See WordPress#86088.
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the |
huzaifaalmesbah
marked this pull request as ready for review
November 1, 2026 02:33
huzaifaalmesbah
requested review from
manzoorwanijk,
spacedmonkey and
tellthemachines
as code owners
November 1, 2026 02:33
westonruter
approved these changes
Nov 1, 2026
westonruter
left a comment
Member
There was a problem hiding this comment.
These same changes were already applied to core in WordPress/wordpress-develop@4a8a86b and WordPress/wordpress-develop@b915feb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
See #86088
Replaces
static::withself::whereWP_Theme_JSON_GutenbergandWP_Theme_JSON_Resolver_Gutenbergcall their own private static methods, and removes the resolved entries from the PHPStan baseline.This is a backport of WordPress Core r63368 and r63384 (see Core-65817).
Why?
PHPStan reports calls to private methods through
static::as unsafe (staticClassAccess.privateMethod): late static binding resolvesstatic::against the called class, where a private method is not visible. Since a subclass can never supply a private method,self::is the accurate reference and behaves identically.WordPress Core already made this change in
WP_Theme_JSONandWP_Theme_JSON_Resolver, so the Gutenberg classes were out of sync with Core. Together, these changes clear 37 of the 226 errors initially baselined in #66693.How?
lib/class-wp-theme-json-gutenberg.php: 14 private static methods, 29 call sites, plus the docblock example oncompute_spacing_sizes(), which Core updated as well.lib/class-wp-theme-json-resolver-gutenberg.php: 5 private static methods, 8 call sites.static::is kept wherever it targets a protected or public method (such asto_ruleset()orcompute_style_properties()), where late static binding is meaningful, matching Core.staticClassAccess.privateMethodentries fromtools/phpstan/baseline.neon.The 6
assign.propertyTypeerrors inWP_Theme_JSON_Resolver_Gutenbergare left as they are, since Core still has the same entries in its baseline.No Core backport is needed, since the change already exists in Core.
Testing Instructions
composer phpstanand confirm it passes with no unmatched ignored errors.composer phpstan:baselinesand confirmtools/phpstan/baseline.neonhas no further changes.npm run test:php -- --filter WP_Theme_JSON.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.