Repository navigation
Exclude the wp-compat false positives from the PHPStan config - #12
Merged
Merged
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 ability-command.php that aborts every `wp ability` command below WordPress 6.9, so all 37 errors it reports are false positives. Ignore them by error identifier and message, naming both the Abilities API symbols and that version, so a call to anything introduced after WordPress 6.9 keeps being reported rather than swallowed by a file-wide ignore. Co-authored-by: Pascal Birchler <pascal.birchler@gmail.com>
|
Warning Review limit reachedNext included review available in 55 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
✨ 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! |
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.
The
johnbillion/wp-compatPHPStan extension that now ships withwp-cli-testsreported 37 errors. It checks every WordPress symbol against the WordPress 4.9 baseline thatwp-cli-testsconfigures, and only recognizesfunction_exists()andmethod_exists()guards.All 37 are false positives, and for the simplest possible reason: every
wp abilitycommand is registered with abefore_invokethat aborts below WordPress 6.9, and every flagged symbol is part of the Abilities API introduced in exactly that version. wp-compat does not look atbefore_invoke, so it reports the lot.wp_get_abilities(),wp_get_ability(),wp_has_ability(),wp_get_ability_categories(),wp_get_ability_category(),wp_has_ability_category()WP_Ability::—check_permissions,execute,get_category,get_description,get_input_schema,get_label,get_meta,get_meta_item,get_name,get_output_schema,normalize_input,validate_inputWP_Ability_Category::—get_description,get_label,get_meta,get_slugIgnored by error identifier and message, naming both the symbols and the version. Matching the version is the part that matters: scoping by class name alone would still have swallowed a hypothetical
WP_Abilitymethod added in a later release, whereas now anything introduced after 6.9 keeps being reported.No source changes: nothing here is an actual compatibility problem.
An observation, not a change
Three of the pre-existing
ignoreErrorspatterns no longer match anything:#Call to an undefined method WP_Ability::##Call to an undefined method WP_Ability_Category::##Cannot access offset string on mixed#The first two are explained by the same dependency bump that motivates this PR —
php-stubs/wordpress-stubsnow carries the Abilities API, so the comment above them ("not yet in stubs") is out of date and the patterns are dead. They are silent because ofreportUnmatched: false.I have deliberately left them alone: that flag looks like intentional tolerance for resolving against an older stubs release, and removing the entries would give that up. Flagging it so you can decide.
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 entries7.0.0instead of6.9.0makes all 37 errors resurface, confirming the version match is load-bearing rather than decorativeGitHub 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