Repository navigation
PHPStan: Fix dynamic calls to process_blocks_custom_css and enable dynamicCallOnStaticMethod rule - #87058
Merged
westonruter merged 5 commits intoNov 19, 2026
Conversation
…namicCallOnStaticMethod rule
🤖 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 |
noruzzamans
marked this pull request as ready for review
November 19, 2026 03:51
noruzzamans
requested review from
fabiankaegy,
juanmaguitar,
tellthemachines and
westonruter
as code owners
November 19, 2026 03:51
westonruter
approved these changes
Nov 19, 2026
Render_Block_MediaText_Test::setup_query() is declared static but was called as $this->setup_query(), which the dynamicCallOnStaticMethod strict rule reports when a local phpstan.neon analyzes phpunit/. Co-Authored-By: Claude Opus 5.5 (medium effort) <noreply@anthropic.com> Claude-Code-Session-Id: dd6ba841-fda3-4a15-8474-62f4e9285131
With dynamicCallOnStaticMethod enabled, a local phpstan.neon that adds phpunit/ to the paths, as the coding guidelines describe, reported thousands of errors, since PHPUnit declares its assertions and markTestSkipped() static while tests call them on $this, as WordPress core's tests do. Register phpstan-phpunit's DynamicCallToAssertionIgnoreExtension, which its extension.neon enables only with bleedingEdge, to ignore $this->assert*() calls, and ignore $this->markTestSkipped() in phpunit/. The latter entry does not report itself as unmatched, since the default configuration does not analyze the tests. Co-Authored-By: Claude Opus 5.5 (medium effort) <noreply@anthropic.com> Claude-Code-Session-Id: dd6ba841-fda3-4a15-8474-62f4e9285131
…atic-method Resolve the conflict in the coding guidelines' local configuration example, where trunk added numericOperandsInArithmeticOperators (from the merged numeric operands PR) and this branch added dynamicCallOnStaticMethod at the same spot. Keep both. Co-Authored-By: Claude Opus 5.5 (medium effort) <noreply@anthropic.com> Claude-Code-Session-Id: dd6ba841-fda3-4a15-8474-62f4e9285131
wporg-sync
pushed a commit
to WordPress/wordpress-develop
that referenced
this pull request
Nov 25, 2026
The `WP_Theme_JSON::process_blocks_custom_css()` method is declared static, yet three of its call sites invoked it through `$this` while the others already used `static::`. Behavior is unchanged, since both forms resolve the method with late static binding. In Gutenberg the same change, made in WordPress/gutenberg#87058, cleared the only errors of the `dynamicCallOnStaticMethod` rule from phpstan-strict-rules, so making it here keeps `WP_Theme_JSON` in sync with its Gutenberg counterpart. Developed in #16093. Follow-up to r55192, r58421. Props noruzzaman, westonruter. See #66739. git-svn-id: https://develop.svn.wordpress.org/trunk@65770 602fd350-edb4-49c9-b593-d223f7449a82
wporg-sync
pushed a commit
to WordPress/WordPress
that referenced
this pull request
Nov 25, 2026
The `WP_Theme_JSON::process_blocks_custom_css()` method is declared static, yet three of its call sites invoked it through `$this` while the others already used `static::`. Behavior is unchanged, since both forms resolve the method with late static binding. In Gutenberg the same change, made in WordPress/gutenberg#87058, cleared the only errors of the `dynamicCallOnStaticMethod` rule from phpstan-strict-rules, so making it here keeps `WP_Theme_JSON` in sync with its Gutenberg counterpart. Developed in WordPress/wordpress-develop#16093. Follow-up to r55192, r58421. Props noruzzaman, westonruter. See #66739. Built from https://develop.svn.wordpress.org/trunk@65770 git-svn-id: http://core.svn.wordpress.org/trunk@64799 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Vedant-Gandhi
pushed a commit
to Vedant-Gandhi/gutenberg
that referenced
this pull request
Nov 30, 2026
…namicCallOnStaticMethod rule (WordPress#87058) * PHPStan: Fix dynamic calls to process_blocks_custom_css and enable dynamicCallOnStaticMethod rule * Add Core backport changelog entry for Core PR 16093 * Call the static setup_query() test helper statically Render_Block_MediaText_Test::setup_query() is declared static but was called as $this->setup_query(), which the dynamicCallOnStaticMethod strict rule reports when a local phpstan.neon analyzes phpunit/. Co-Authored-By: Claude Opus 5.5 (medium effort) <noreply@anthropic.com> * Ignore dynamic calls to PHPUnit's static assertions in tests With dynamicCallOnStaticMethod enabled, a local phpstan.neon that adds phpunit/ to the paths, as the coding guidelines describe, reported thousands of errors, since PHPUnit declares its assertions and markTestSkipped() static while tests call them on $this, as WordPress core's tests do. Register phpstan-phpunit's DynamicCallToAssertionIgnoreExtension, which its extension.neon enables only with bleedingEdge, to ignore $this->assert*() calls, and ignore $this->markTestSkipped() in phpunit/. The latter entry does not report itself as unmatched, since the default configuration does not analyze the tests. Co-Authored-By: Claude Opus 5.5 (medium effort) <noreply@anthropic.com> --------- Co-authored-by: noruzzamans <noruzzaman@git.wordpress.org> Co-authored-by: westonruter <westonruter@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?
Follow up to #86460.
Replaces three dynamic
$this->process_blocks_custom_css()calls withstatic::process_blocks_custom_css()inWP_Theme_JSON_Gutenberg, and enables thedynamicCallOnStaticMethodstrict rules inphpstan.neon.dist.Why?
WP_Theme_JSON_Gutenberg::process_blocks_custom_css()is declaredpublic static. In three locations withinWP_Theme_JSON_Gutenberg, it was being called dynamically via$this->instead ofstatic::.As documented in #86460, these three calls were the only errors preventing
dynamicCallOnStaticMethodfrom being enabled. Fixing them brings the Gutenberg codebase into full compliance and enables the strict rule by default, ensuring all static method calls and callables are invoked statically.The equivalent calls exist in WordPress core's
WP_Theme_JSON(lines 2286, 4205, 4537), which can be synced to core.How?
process_blocks_custom_css()inlib/class-wp-theme-json-gutenberg.phpto usestatic::instead of$this->:get_block_custom_css()(line 2312)get_styles_for_block()for style variations (line 4269)get_styles_for_block()for block custom CSS (line 4614)DynamicCallOnStaticMethodsRuleandDynamicCallOnStaticMethodsCallableRuleunderrules:inphpstan.neon.dist.docs/contributors/code/coding-guidelines.mdto disabledynamicCallOnStaticMethod: falsewhen a localphpstan.neonincludesrules.neon.Testing Instructions
composer phpstan(ornpm run typecheck:php). Verify analysis finishes with zero errors across all 327 analyzed files.vendor/bin/phpcs lib/class-wp-theme-json-gutenberg.php. Verify 0 errors and 0 warnings.$this->process_blocks_custom_css(). Runcomposer phpstanand verifystaticMethod.dynamicCallis reported.