Exclude the wp-compat false positives from the PHPStan config - #28
Conversation
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>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe PHPStan configuration adds narrowly scoped ChangesPHPStan compatibility configuration
Estimated code review effort: 1 (Trivial) | ~3 minutes Merge Risk: ⚪ Minimal · up to 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: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation 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)
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
The
johnbillion/wp-compatPHPStan extension that now ships withwp-cli-testsreported eight errors. It checks every WordPress symbol against the WordPress 4.9 baseline thatwp-cli-testsconfigures, and only recognizesfunction_exists()andmethod_exists()guards.All eight are false positives, for a straightforward reason: both
wp aiandwp connectorsare registered with abefore_invokethat aborts below WordPress 7.0, and every flagged function is part of the APIs introduced in that release. wp-compat does not look atbefore_invoke, so it reports the lot.wp_supports_ai(),wp_ai_client_prompt()src/AI_Command.phpwp_get_connectors(),wp_get_connector()src/Connectors_Command.phpIgnored by error identifier and message, naming both the functions and the version. Matching the version is the part that matters:
WPCompat.functionNotAvailableon 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
ignoreErrorskey tophpstan.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-compat2.0.0,php-stubs/wordpress-stubsv6.9.4,wp-cli/wp-cli-testsv5.2.3):composer phpstan—[OK] No errors, with no unmatched ignore entriesignore.unmatchederror, confirming the entries above match real errors rather than sitting there unusedGitHub 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