phpcompatibility/php-compatibility
PHPCompatibility is a PHP_CodeSniffer ruleset that scans PHP code for cross-version compatibility issues. Check support for specific PHP versions, detect deprecated/removed features, and audit projects when upgrading or maintaining multi-version support.
Architecture fit: The package integrates as a PHP_CodeSniffer (PHPCS) standard, seamlessly extending existing static analysis workflows without altering core architecture. It operates as a ruleset plugin, leveraging PHPCS's plugin system for code inspection, making it a natural fit for projects already using PHPCS for linting or style checks. No architectural changes are required beyond standard PHPCS configuration.
Integration feasibility: High. Composer-based installation automatically registers the standard with PHPCS via the PHPCS installer plugin. Minimal configuration is needed (e.g., setting testVersion), and it works with common CI/CD pipelines (e.g., GitHub Actions, GitLab CI). The package supports both project-local and global installations, accommodating diverse team workflows.
Technical risk: Medium. Dependencies require PHPCS 4.0.1+ and PHP 7.2+ for the tool itself—older PHPCS versions or PHP 7.1 environments would need upgrades. Coverage gaps for legacy PHP versions (pre-5.1) may yield false negatives. False positives from extension conflicts (e.g., userland functions matching removed extensions) require manual whitelisting, adding maintenance overhead. The package's active maintenance mitigates long-term risks, but PHPCS breaking changes could necessitate updates.
Key questions: What is the project's current PHPCS version and PHP runtime? Are there legacy code sections using polyfills or custom extensions that need whitelisting? How will false positives be managed (e.g., prioritization strategy, team training)? What PHP versions must the code support (e.g., testVersion range)?
Stack fit: Perfect alignment with PHP tooling stacks. Complements existing PHPCS rules (e.g., PSR-12, WordPress Coding Standards) by adding version-specific compatibility checks. Works with common CI/CD tools (e.g., GitHub Actions, Jenkins) and IDE integrations (e.g., VS Code PHPCS extensions). No new infrastructure or dependencies beyond Composer and PHPCS.
Migration path: For projects without PHPCS: 1) Install PHPCS via Composer, 2) Add PHPCompatibility, 3) Run initial checks with --testVersion. For existing PHPCS users: 1) Add PHPCompatibility to composer.json, 2) Extend the existing ruleset to include PHPCompatibility, 3) Configure testVersion in the ruleset or CLI. Start with a narrow testVersion (e.g
How can I help you explore Laravel packages today?