talira

PHPCompatibilityWP

PHPCompatibility ruleset for WordPress projects that skips WordPress's own polyfills

open sourceLGPL-3.0-or-laterfree

PHPCompatibilityWP is a ruleset for PHP_CodeSniffer that checks a WordPress-based project for PHP cross-version compatibility. It builds on PHPCompatibility and excludes the back-fills and polyfills WordPress provides, so code that relies on them isn't flagged. Set a testVersion to check both removed and new PHP features against the PHP versions you support.

Problems it solves

  • check whether my WordPress plugin's PHP code runs on the PHP versions WordPress supports
  • stop PHP compatibility checks flagging functions WordPress already polyfills
  • lint a WordPress theme for PHP version compatibility before raising the minimum PHP version

Features

  • PHP cross-version compatibility checks for WordPress projects
  • excludes polyfills and back-fills WordPress provides, to avoid false positives
  • testVersion set per run or in a custom ruleset

Limitations

  • Needs PHP 7.2+, PHP_CodeSniffer 4.0.2+, PHPCompatibility 10+ and PHPCompatibilityParagonie 2+; Composer is the only supported install method.1

Alternatives

The same job

These do what PHPCompatibilityWP does.

  1. WordPress Coding Standards for PHP_CodeSniffer PHP_CodeSniffer rules that enforce WordPress coding conventions
  2. PHPCompatibility PHP_CodeSniffer sniffs that check PHP code for cross-version compatibility
  3. PHP_CodeSniffer Standards Composer Installer Plugin Composer plugin that registers installed PHP_CodeSniffer coding standards automatically

Compare PHPCompatibilityWP with the top 3