Repository navigation
PHPStan: Treat IS_GUTENBERG_PLUGIN as a dynamic constant - #86093
Merged
westonruter merged 1 commit intoNov 1, 2026
Merged
westonruter merged 1 commit into
westonruter merged 1 commit into
Conversation
`lib/load.php` defines `IS_GUTENBERG_PLUGIN` as `true`, so PHPStan reported every `defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN` check as always true. These checks are intentional: the block library and other packages are copied into WordPress Core, where the constant is not defined. Add the constant to `dynamicConstantNames` and remove the 9 resolved entries from the 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:09
westonruter
approved these changes
Nov 1, 2026
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
Adds
IS_GUTENBERG_PLUGINto PHPStan'sdynamicConstantNamesand removes the resolved entries from the PHPStan baseline.Why?
lib/load.phpdefinesIS_GUTENBERG_PLUGINastrue, so PHPStan treats the constant as always true and reports everydefined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGINcheck asbooleanAnd.rightAlwaysTrue.These checks are not dead code. The block library and
core-actionsare copied into WordPress Core, where the constant is not defined, and the checks keep plugin-only behavior (such as the__unstableLocationfeature) out of Core. Removing them would be wrong, so the fix belongs in the configuration rather than the code.Together, these changes clear 9 of the 226 errors initially baselined in #66693.
How?
IS_GUTENBERG_PLUGINtodynamicConstantNamesintools/phpstan/base.neon, next toMEDIA_TRASH, so PHPStan treats its value as unknown.booleanAnd.rightAlwaysTrueentries fromtools/phpstan/baseline.neon:lib/client-assets.php(1),navigation-link(2),navigation-submenu(3),core-actions(1), and 2 of the 3 innavigation.No PHP source files are changed.
Testing Instructions
composer phpstanand confirm it passes with no unmatched ignored errors.composer phpstan:baselinesand confirmtools/phpstan/baseline.neonhas 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.