Skip to content

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

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#28
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 reported eight errors. It checks every WordPress symbol against the WordPress 4.9 baseline that wp-cli-tests configures, and only recognizes function_exists() and method_exists() guards.

All eight are false positives, for a straightforward reason: both wp ai and wp connectors are registered with a before_invoke that aborts below WordPress 7.0, and every flagged function is part of the APIs introduced in that release. wp-compat does not look at before_invoke, so it reports the lot.

Count Functions Where Version
6 wp_supports_ai(), wp_ai_client_prompt() src/AI_Command.php 7.0.0
2 wp_get_connectors(), wp_get_connector() src/Connectors_Command.php 7.0.0

Ignored by error identifier and message, naming both the functions and the version. Matching the version is the part that matters: WPCompat.functionNotAvailable on its own would cover every diagnostic of that kind in these files, so a call to something introduced after 7.0 would be swallowed silently. With the version pinned it still gets reported.

This adds the ignoreErrors key to phpstan.neon.dist, which did not have one.

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 handle known WordPress compatibility warnings.
    • No user-facing functionality changes.

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, and only recognizes function_exists() and method_exists() guards.
It cannot see the `before_invoke` check in ai-command.php that aborts `wp ai`
and `wp connectors` below WordPress 7.0, so all eight errors it reports are
false positives.

Ignore them by error identifier and message, naming both the functions and that
version, so a call to anything introduced after WordPress 7.0 keeps being
reported rather than swallowed by a file-wide ignore.

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

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.

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: 9ec69414-b37e-4655-b2e1-f79d8a5144ae

📥 Commits

Reviewing files that changed from the base of the PR and between a1e4195 and 376b08a.

📒 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

The PHPStan configuration adds narrowly scoped WPCompat.functionNotAvailable suppressions for four WordPress functions used by the command files.

Changes

PHPStan compatibility configuration

Layer / File(s) Summary
Scoped WordPress compatibility suppressions
phpstan.neon.dist
Adds identifier-, message-, and path-constrained suppressions for four WordPress 7.0 availability warnings.

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

Merge Risk: ⚪ Minimal · up to 376b0

This localized configuration change only suppresses documented PHPStan false positives and does not alter product behavior; no actionable merge-blocking risk remains after normal checks and review.

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:ai Related to 'ai' command command:connectors Related to 'connectors' 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 1.0.3 milestone Aug 26, 2026
@swissspidy
swissspidy merged commit f17a659 into main Aug 26, 2026
52 checks passed
@swissspidy
swissspidy deleted the fix/phpstan-wp-compat branch August 26, 2026 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:ai Related to 'ai' command command:connectors Related to 'connectors' command scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants