Skip to content

Add WP-Compat PHPStan extension configuration - #360

Merged
swissspidy merged 1 commit into
mainfrom
wp-compat-v2-setup-gzr4mn
Aug 25, 2026
Merged

Add WP-Compat PHPStan extension configuration#360
swissspidy merged 1 commit into
mainfrom
wp-compat-v2-setup-gzr4mn

Conversation

@swissspidy

@swissspidy swissspidy commented Aug 25, 2026

Copy link
Copy Markdown
Member

This PR integrates the WP-Compat PHPStan extension to enable WordPress compatibility checking in the codebase.

Summary

Added configuration and schema definitions for the WP-Compat PHPStan extension to validate code compatibility with WordPress versions.

Key Changes

  • Added johnbillion/wp-compat dependency to composer.json
  • Configured WP-Compat parameters in extension.neon:
    • Set pluginFile to null (default behavior)
    • Set requiresAtLeast to '4.9' (oldest supported WordPress version for WP-CLI)
  • Added parametersSchema definition for WP-Compat to make the configuration available without explicitly loading the extension

Implementation Details

The schema definition allows both pluginFile and requiresAtLeast to be nullable strings, providing flexibility in configuration while maintaining type safety through PHPStan's schema validation.

https://claude.ai/code/session_01NADf5amDBgJ4ZBbd2qgijy

Summary by CodeRabbit

  • New Features
    • Added WordPress compatibility checks for projects targeting WordPress 4.9 or later.
    • Added configuration options for specifying the plugin file and minimum supported WordPress version.
  • Documentation
    • Updated configuration schema guidance to include the new compatibility settings.

Adds the wp-compat PHPStan extension, which reports usage of WordPress
functions, classes, methods and constants that are not available in the
oldest supported WordPress version.

`requiresAtLeast` is set to 4.9 in `extension.neon` so that all packages
using this testing framework inherit the check. `pluginFile` is set to
its default of `null` because wp-compat otherwise tries to determine the
minimum version from a plugin or theme header.

The parameters schema is declared here as well, mirroring what is
already done for phpstan-strict-rules, so that the configuration remains
valid when the extension is not loaded through
phpstan/extension-installer.

Co-authored-by: Pascal Birchler <pascal.birchler@gmail.com>
Claude-Session: https://claude.ai/code/session_01NADf5amDBgJ4ZBbd2qgijy
Copilot AI lite review requested due to automatic review settings August 25, 2026 08:34
@swissspidy
swissspidy requested a review from a team as a code owner August 25, 2026 08:34

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 25, 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: fbc8424c-97a1-4eaa-b730-176b707bb5b0

📥 Commits

Reviewing files that changed from the base of the PR and between 515843e and 528f23a.

📒 Files selected for processing (2)
  • composer.json
  • extension.neon

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


📝 Walkthrough

Walkthrough

The project adds johnbillion/wp-compat as a production dependency. PHPStan configuration now defines default WPCompat parameters and validates them through parametersSchema.

Changes

WP Compat integration

Layer / File(s) Summary
Add wp-compat dependency and PHPStan configuration
composer.json, extension.neon
Adds johnbillion/wp-compat version ^2.0. Defines WPCompat.pluginFile and WPCompat.requiresAtLeast defaults and nullable string schemas. Updates the schema comment.
Estimated code review effort: 2 (Simple) ~10 minutes

Merge Risk: ⚪ Minimal · up to 528f2

This PR adds WordPress compatibility checks through a dependency and configuration update without any actionable merge-blocking risk remaining 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: adding WP-Compat PHPStan extension 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. (2 skipped: 2 unsupported.)

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch wp-compat-v2-setup-gzr4mn

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 the scope:testing Related to testing label Aug 25, 2026
@codecov

codecov Bot commented Aug 25, 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 5.2.3 milestone Aug 25, 2026
@swissspidy
swissspidy merged commit d11decc into main Aug 25, 2026
71 checks passed
@swissspidy
swissspidy deleted the wp-compat-v2-setup-gzr4mn branch August 25, 2026 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants