Skip to content

Exclude the wp-compat false positives from the PHPStan config - #145

Merged
swissspidy merged 1 commit into
mainfrom
fix/phpstan-wp-compat
Aug 26, 2026
Merged

Exclude the wp-compat false positives from the PHPStan config#145
swissspidy merged 1 commit into
mainfrom
fix/phpstan-wp-compat

Conversation

@swissspidy

@swissspidy swissspidy commented Aug 26, 2026

Copy link
Copy Markdown
Member

The johnbillion/wp-compat PHPStan extension that now ships with wp-cli-tests checks every WordPress symbol against the WordPress 4.9 baseline that wp-cli-tests configures. It reported six errors here, and all six are the same false positive in two flavours.

Count Reported Where Why it is a false positive
3 Parameter $args of apply_filters() is only available since WordPress version 6.0.0 src/WP_Export_Query.php WordPress 6.0 only "formalized the existing and already documented ...$args parameter by adding it to the function signature"
3 Parameter $arg of do_action() is only available since WordPress version 5.3.0 src/WP_Export_Returner.php, src/WP_Export_Split_Files_Writer.php, src/WP_Export_XML_Over_HTTP.php Same story for do_action() in WordPress 5.3

In both cases the extra arguments were collected through func_get_args() long before the signatures changed, so passing them to the_generator, export_term_orphaned, wp_export_new_file and friends has always worked.

Ignored by error identifier and path. No message scoping was needed: WPCompat.parameterNotAvailable.applyfilters.args and WPCompat.parameterNotAvailable.doaction.arg already name one specific parameter of one specific function, so these entries cannot swallow an unrelated diagnostic.

No source changes: nothing here is an actual compatibility problem.

Verification

Run locally against the same dependency versions CI resolves (johnbillion/wp-compat 2.0.0, php-stubs/wordpress-stubs v6.9.4, wp-cli/wp-cli-tests v5.2.3):

  • composer phpstan[OK] No errors, with no unmatched ignore entries
  • As a control, adding a deliberately dead ignore entry does produce an ignore.unmatched error, confirming the entries above match real errors rather than sitting there unused

GitHub Actions was failing to allocate runners across the org while this was written, so CI may need a re-run once that clears.


Generated by Claude Code

Summary by CodeRabbit

  • Chores
    • Updated static analysis configuration to account for historically supported WordPress compatibility patterns.
    • Added documentation comments explaining the compatibility exceptions.

The johnbillion/wp-compat extension that comes with wp-cli-tests checks every
WordPress symbol against the WordPress 4.9 baseline that wp-cli-tests
configures. All six errors it reported are false positives of the same kind:
WordPress 6.0 and 5.3 merely formalized the already documented `...$args` and
`...$arg` parameters of `apply_filters()` and `do_action()` by adding them to
the function signatures, so passing extra arguments to `the_generator`,
`export_term_orphaned` and the other hooks has always worked.

Co-authored-by: Pascal Birchler <pascal.birchler@gmail.com>
Copilot AI lite review requested due to automatic review settings August 26, 2026 06:43
@swissspidy
swissspidy requested a review from a team as a code owner August 26, 2026 06:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: fea36aad-dcb3-49a1-9d76-41efbd7802c3

📥 Commits

Reviewing files that changed from the base of the PR and between 5541c04 and 0bdf06a.

📒 Files selected for processing (1)
  • phpstan.neon.dist

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

PHPStan configuration adds targeted WPCompat.parameterNotAvailable ignores for variadic apply_filters() and do_action() parameters used by export-related source files.

Changes

WordPress compatibility analysis

Layer / File(s) Summary
Document targeted WP compatibility exceptions
phpstan.neon.dist
Adds documentation and targeted ignores for historical WordPress compatibility warnings on variadic apply_filters() and do_action() parameters.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Merge Risk: ⚪ Minimal · up to 0bdf0

This change only excludes two narrowly identified PHPStan false-positive diagnostics and does not alter runtime or product behavior. It is merge-ready after normal checks, with no actionable merge-blocking risk remaining.

Suggested reviewers: brianhenryie

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: excluding WordPress compatibility false positives from the PHPStan configuration.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/phpstan-wp-compat

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added command:export Related to 'export' command scope:testing Related to testing labels Aug 26, 2026
@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@swissspidy swissspidy added this to the 3.0.1 milestone Aug 26, 2026
@swissspidy
swissspidy merged commit 36353d0 into main Aug 26, 2026
57 checks passed
@swissspidy
swissspidy deleted the fix/phpstan-wp-compat branch August 26, 2026 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:export Related to 'export' command scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants