Skip to content

Build/Test Tools: Avoid passing an object when invoking static methods via Reflection - #15422

Closed
desrosj wants to merge 1 commit into
WordPress:trunkfrom
desrosj:fix/php86-reflection-static-invoke
Closed

desrosj wants to merge 1 commit into
WordPress:trunkfrom
desrosj:fix/php86-reflection-static-invoke

Conversation

@desrosj

@desrosj desrosj commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

PHP 8.6 deprecates passing an object to ReflectionMethod::invoke() and ReflectionMethod::invokeArgs() when the target method is static (RFC, php/php-src#23223). This causes 15 errors in the PHP 8.6 PHPUnit jobs:

Calling ReflectionMethod::invokeArgs() for static method WP_Plugin_Dependencies::get_circular_dependencies() does not need an object parameter
Calling ReflectionMethod::invoke() for static method WP_Theme_JSON::process_blocks_custom_css() does not need an object parameter

Changes:

  • tests/phpunit/tests/admin/plugin-dependencies/base.php: the call_method() helper now passes null when the reflected method is static, and the instance otherwise.
  • tests/phpunit/tests/theme/wpThemeJson.php: WP_Theme_JSON::process_blocks_custom_css() has been public static since 7.0.0, so the test now calls it directly instead of through Reflection.

I audited every invoke()/invokeArgs() call in src/ and tests/, and these are the only two places that pass an object for a static method. Production code doesn't invoke methods through Reflection.

Trac ticket: Core-66457.

Use of AI Tools

Claude Code (Claude Opus 5.5) analyzed the PHP 8.6 CI failures, audited the codebase for other instances and drafted the changes. I reviewed the changes.

🤖 Generated with Claude Code

…s via Reflection.

PHP 8.6 deprecates passing an object to `ReflectionMethod::invoke()` and `ReflectionMethod::invokeArgs()` when the method is static.

This updates the `call_method()` helper in the plugin dependencies tests to pass `null` for static methods, and calls the public static `WP_Theme_JSON::process_blocks_custom_css()` method directly instead of through Reflection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the test-only PHP 8.6 deprecation changes.

No open issues 🎉

What changed in this PR

Updates PHPUnit tests to avoid PHP 8.6 deprecations caused by passing objects when invoking static methods through Reflection. Production code is unchanged.

Changes:

  • Passes null for static methods in the plugin-dependency test helper, while retaining the instance for non-static methods.
  • Replaces Reflection with a direct call to the public static WP_Theme_JSON::process_blocks_custom_css() method.
File Description
tests/​phpunit/​tests/​theme/​wpThemeJson.php Calls the public static method directly and removes unnecessary setup.
tests/​phpunit/​tests/​admin/​plugin-dependencies/​base.php Selects the appropriate object argument for reflected method calls.

Review effort: Balanced

@desrosj
desrosj marked this pull request as ready for review November 3, 2026 17:44
@desrosj desrosj self-assigned this Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs.

Core Committers: Use this line as a base for the props when committing in SVN:

Props desrosj, westonruter.

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.

@desrosj desrosj moved this from In review to Ready in WordPress Project Build Tooling Nov 3, 2026
@desrosj desrosj added the props-bot Adding this label triggers the Props Bot workflow for a PR. label Nov 3, 2026
@github-actions github-actions Bot removed the props-bot Adding this label triggers the Props Bot workflow for a PR. label Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 65248
GitHub commit: 65b18f9

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants