Repository navigation
Navigation: Use self:: to access private static members - #86090
Merged
westonruter merged 1 commit intoNov 1, 2026
Merged
westonruter merged 1 commit into
westonruter merged 1 commit into
Conversation
`WP_Navigation_Block_Renderer` accessed its private static methods and properties through `static::`, which PHPStan reports as unsafe since a subclass cannot see private members. Use `self::` instead and remove the 27 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 01:42
huzaifaalmesbah
requested review from
fabiankaegy and
manzoorwanijk
as code owners
November 1, 2026 01:42
westonruter
approved these changes
Nov 1, 2026
Vedant-Gandhi
pushed a commit
to Vedant-Gandhi/gutenberg
that referenced
this pull request
Nov 30, 2026
) `WP_Navigation_Block_Renderer` accessed its private static methods and properties through `static::`, which PHPStan reports as unsafe since a subclass cannot see private members. Use `self::` instead and remove the 27 resolved entries from the PHPStan baseline. See WordPress#86088. Co-authored-by: huzaifaalmesbah <huzaifaalmesbah@git.wordpress.org>
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::whenWP_Navigation_Block_Rendereraccesses its own private static methods and properties, and removes the resolved entries from the PHPStan baseline.Why?
PHPStan reports calls to private methods and access to private properties through
static::as unsafe (staticClassAccess.privateMethodandstaticClassAccess.privateProperty). Late static binding withstatic::implies that a subclass may provide the member, but a subclass can never see a private member, soself::is the accurate reference. Together, these changes clear 49 of the 226 errors initially baselined in #66693.How?
static::withself::inpackages/block-library/src/navigation/index.php. Every occurrence refers to a private member of the class itself, and the only public method,render(), is not called throughstatic::.staticClassAccess.*entries for this file fromtools/phpstan/baseline.neon.There is no change in behavior: the class has no subclasses, and private members resolve to the declaring class either way.
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_Navigation_Block_Renderer_Test.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.