Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Phpcompatibility Wp Laravel Package

phpcompatibility/phpcompatibility-wp

WordPress-focused PHP_CodeSniffer ruleset for checking PHP cross-version compatibility. Built on PHPCompatibility, it avoids false positives by excluding WordPress backfills and polyfills so you can scan WP plugins, themes, and sites accurately.

View on GitHub
Deep Wiki
Context7

Getting Started

Start by installing the package via Composer as a development dependency. Run composer require --dev phpcompatibility/phpcompatibility-wp:^3.0@dev in your WordPress project root (e.g., plugin, theme, or core derivative). The package automatically registers itself with PHP_CodeSniffer using the Composer PHPCS plugin—no manual configuration needed. Verify installation by running vendor/bin/phpcs -i; you should see PHPCompatibilityWP listed as an available standard. First use case: run vendor/bin/phpcs --standard=PHPCompatibilityWP --runtime-set testVersion 7.2- ./ to scan your codebase for PHP compatibility issues relevant to your target WordPress minimum PHP version (e.g., PHP 7.2 for WP 6.6+). Always specify testVersion—this enables detection of both deprecated/removed features and usage of newer PHP features not supported in your chosen baseline.

Implementation Patterns

  • CI Integration: Include the command in your CI pipeline (e.g., GitHub Actions, GitLab CI). Use --extensions=php to skip non-PHP files for speed, and consider caching vendor/ for faster runs.
  • Custom Ruleset: Create a .phpcs.xml.dist file to set defaults (e.g., testVersion, error Severity, warning Severity) and exclude paths. Example:
    <?xml version="1.0"?>
    <ruleset name="WordPressPHPCompatibility">
      <config name="testVersion" value="8.0-"/>
      <rule ref="PHPCompatibilityWP">
        <exclude name="PHPCompatibilityWP.Core.RewriteAPI.UseAdd_rewrite_rule_DEPRECATED"/>
      </rule>
      <file>.</file>
      <arg name="extensions" value="php"/>
    </ruleset>
    
  • Theme/Plugin Development Workflow: Run checks locally before committing (git pre-commit hook recommended). Integrate with IDEs like VS Code via the PHP_CodeSniffer extension, setting phpcs.standard to PHPCompatibilityWP.
  • Baseline Generation: For large codebases, generate a baseline to suppress known issues temporarily: vendor/bin/phpcs --standard=PHPCompatibilityWP --runtime-set testVersion 8.0- --ignore-annotations --report=baseLine > phpcs-baseline.xml, then reference it in .phpcs.xml.

Gotchas and Tips

  • testVersion Quirks: The trailing dash (-) matters—it means “and higher”. Using 7.2 (without -) checks only PHP 7.2 features, missing deprecations for newer versions. Confirm your WordPress minimum version: e.g., WP 6.9 requires PHP 7.2.24+, so use testVersion 7.2.24-.
  • False Positives Still Possible: Though phpcompatibility-wp filters out known WordPress polyfills (e.g., sodium_compat, wp_rand backfill), some edge cases remain (e.g., using IntlDateFormatter with Intl extension not loaded in older PHP versions but polyfilled in WP). Always validate warnings manually.
  • Upgrade Pitfalls: Major updates (e.g., v2.x → 3.x) may change sniff codes (e.g., PHPCompatibilityWP.Core.*PHPCompatibilityWP.*). Update // phpcs:ignore comments and custom excludes accordingly—consult the changelog and PHPCompatibility 10 upgrade guide.
  • PHP Compatibility Version Alignment: Ensure phpcompatibility/phpcompatibility and phpcompatibility/phpcompatibility-paragonie are at compatible versions. The --with-dependencies flag is crucial during updates: composer update --dev phpcompatibility/phpcompatibility-wp --with-dependencies.
  • Debugging Slow Runs: Use vendor/bin/phpcs -v for verbose output to pinpoint slow sniffs. For large projects, run on subsets: vendor/bin/phpcs ./plugins/my-plugin/src/ --standard=PHPCompatibilityWP --runtime-set testVersion 8.0-.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope