Fix PHP 8.0+ compatibility by upgrading PHP-DI to 7.x - #113
Conversation
- Upgrade PHP-DI from 6.4.0 to 7.1.1 - Update PHP requirement from ^7.4 to ^8.0 - Update composer platform config to PHP 8.0.0 - Update PSR Container from 1.1.2 to 2.0.2 - Remove php-di/phpdoc-reader (no longer needed) - Update plugin headers to require PHP 8.0 - Update developer documentation to PHP 8.0 - Update GitHub Actions CI to use PHP 8.0 - Add Woocommerce_Gateway_Monei stub to PHPStan bootstrap This fixes fatal error reported by customer running PHP 8.1.33: "Declaration of DI\Container::has(name) must be compatible with Psr::has(stringid): bool" PHP-DI 6.4.0 is incompatible with PHP 8.0+ due to PSR-11 method signature mismatches. PHP-DI 7.0+ requires PHP 8.0 minimum and provides full PHP 8.x compatibility. No code changes required - existing DI container usage (autowire, create, get, factory) is fully compatible with PHP-DI 7. BREAKING CHANGE: PHP 7.4 users cannot upgrade. PHP 8.0 is now the minimum required version. PHP 7.4 reached end-of-life in November 2022. WordPress 6.8 officially supports PHP 8.0-8.3.
There was a problem hiding this comment.
Pull Request Overview
This PR upgrades PHP-DI from 6.4.0 to 7.1.1 to resolve a fatal error on PHP 8.x caused by PSR-11 Container interface incompatibility. The upgrade requires bumping the minimum PHP version from 7.4 to 8.0.
Key Changes:
- Upgraded PHP-DI to version 7.1.1 for PSR-11 2.0 compatibility
- Updated minimum PHP requirement from 7.4 to 8.0
- Added PHPStan bootstrap stub for
Woocommerce_Gateway_Moneiclass
Reviewed Changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| composer.json | Updated PHP requirement to ^8.0 and PHP-DI to ^7.0 |
| woocommerce-gateway-monei.php | Updated plugin header to require PHP 8.0 |
| readme.txt | Updated PHP requirement and added v7.0.0 changelog |
| README.md | Updated PHP requirement and added v7.0.0 changelog |
| DEVELOPER.md | Updated developer documentation to specify PHP 8.0+ requirement |
| .github/workflows/code-quality.yml | Updated CI workflow to use PHP 8.0 |
| tests/phpstan-bootstrap.php | Added mock class for PHPStan analysis |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughThe changes update PHP minimum requirements to 8.0 across docs, metadata, CI, and composer constraints; upgrade php-di/php-di to ^7.0; adjust the GitHub Actions workflow to use PHP 8.0; and add a PHPStan bootstrap mock class for Woocommerce_Gateway_Monei. No runtime control flow changes in the plugin code. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
DEVELOPER.md (1)
343-345: Optional: Consider wrapping bare URLs in angle brackets.Markdownlint flags bare URLs on these lines. While this doesn't affect functionality, you could wrap them in angle brackets for better Markdown compliance:
- Documentation: https://support.monei.com - Email: support@monei.com - WordPress.org: https://wordpress.org/plugins/monei/ + Documentation: <https://support.monei.com> + Email: <support@monei.com> + WordPress.org: <https://wordpress.org/plugins/monei/>
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
composer.lockis excluded by!**/*.lock
📒 Files selected for processing (7)
.github/workflows/code-quality.yml(1 hunks)DEVELOPER.md(9 hunks)README.md(1 hunks)composer.json(2 hunks)readme.txt(1 hunks)tests/phpstan-bootstrap.php(1 hunks)woocommerce-gateway-monei.php(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
tests/phpstan-bootstrap.php
📄 CodeRabbit inference engine (CLAUDE.md)
Update tests/phpstan-bootstrap.php when introducing new plugin constants, global helpers, or legacy classes used in analysis
Files:
tests/phpstan-bootstrap.php
**/*
⚙️ CodeRabbit configuration file
**/*: Generate manual testing checkboxes for the PR. The checkboxes should cover:
- Visual verification that the UI renders correctly
- Functional testing of user interactions
- Edge cases and error states
- Cross-browser/device testing if applicable
- Integration with related features
Files:
tests/phpstan-bootstrap.phpREADME.mdreadme.txtcomposer.jsonDEVELOPER.mdwoocommerce-gateway-monei.php
🧬 Code graph analysis (1)
tests/phpstan-bootstrap.php (1)
class-woocommerce-gateway-monei.php (2)
Woocommerce_Gateway_Monei(21-435)instance(52-58)
🪛 markdownlint-cli2 (0.18.1)
DEVELOPER.md
343-343: Bare URL used
(MD034, no-bare-urls)
344-344: Bare URL used
(MD034, no-bare-urls)
345-345: Bare URL used
(MD034, no-bare-urls)
🔇 Additional comments (8)
README.md (1)
8-8: LGTM! PHP requirement updated consistently.The minimum PHP requirement metadata has been correctly updated to 8.0, aligning with the dependency upgrades in composer.json and the PHP 8.0+ compatibility fixes.
woocommerce-gateway-monei.php (1)
19-19: LGTM! Plugin header updated correctly.The PHP requirement in the plugin header has been correctly updated to 8.0, consistent with the broader PHP version upgrade.
readme.txt (1)
7-7: LGTM! WordPress.org metadata updated correctly.The PHP requirement in readme.txt has been correctly updated to 8.0, ensuring the WordPress.org plugin directory displays accurate compatibility information.
composer.json (2)
34-34: Platform PHP version updated correctly.The platform PHP version has been correctly updated to 8.0.0, ensuring Composer resolves dependencies compatible with PHP 8.0+.
3-5: Approve PHP 8.0 requirement and DI dependency upgrades.composer.json and composer.lock have been updated correctly (php-di/php-di 7.1.1, psr/container 2.0.2, platform.php ^8.0). No further changes needed.
Manual testing checklist:
- Visual verification that the UI renders correctly
- Functional testing of user interactions
- Edge cases and error states
- Cross-browser/device testing if applicable
- Integration with related features
.github/workflows/code-quality.yml (1)
21-21: LGTM! CI PHP version updated correctly.The CI workflow now runs on PHP 8.0, ensuring code quality checks are performed on the minimum supported PHP version. This is essential for catching PHP 8.0-specific compatibility issues early.
tests/phpstan-bootstrap.php (1)
236-250: LGTM! PHPStan bootstrap mock class added correctly.The mock class for
Woocommerce_Gateway_Moneihas been correctly added to support PHPStan static analysis. The simplified implementation (without the full singleton pattern) is appropriate for a test bootstrap stub, as PHPStan only needs the method signatures and return types.As per coding guidelines.
DEVELOPER.md (1)
20-20: LGTM! Prerequisites updated to PHP 8.0+.The PHP prerequisite has been correctly updated from PHP 7.4 to PHP 8.0, consistent with the dependency upgrades and minimum requirements across the project.
Summary
Fixes fatal error on PHP 8.x caused by PHP-DI 6.4.0 incompatibility with PSR-11 Container interface.
Customer reported error on PHP 8.1.33:
Changes
Woocommerce_Gateway_MoneistubCompatibility Analysis
✅ No code changes required - all existing DI usage patterns compatible:
autowire()- ✅ Workscreate()- ✅ Worksget()- ✅ Worksfactory()- ✅ Works@Injectannotations found (would require migration to#[Inject])Breaking Change
Justification:
Test Plan
Files Changed
composer.json- PHP & PHP-DI version requirementscomposer.lock- Dependency lockfilewoocommerce-gateway-monei.php- Plugin headerreadme.txt- WordPress.org readmeREADME.md- GitHub readmeDEVELOPER.md- Developer documentation.github/workflows/code-quality.yml- CI PHP versiontests/phpstan-bootstrap.php- PHPStan mock classSummary by CodeRabbit
Chores
Documentation
Tests