Bump minimum PHP requirement to 7.4.12 to avoid covariant return type…#247
Bump minimum PHP requirement to 7.4.12 to avoid covariant return type…#247vyskoczilova wants to merge 5 commits into
Conversation
… fatal (#1) PHP 7.4.0–7.4.11 have a known engine bug (https://bugs.php.net/bug.php?id=80126) that causes a fatal error when a class method returns a more specific type than its interface declares. The DTO inheritance pattern used throughout this project (e.g. GenerativeAiResult::fromArray returning GenerativeAiResult instead of WithArrayTransformationInterface) triggers this exact bug on affected patch releases. The bug was fixed in PHP 7.4.12. Updates composer.json require and platform config, CONTRIBUTING.md compatibility note, and AGENTS.md key constraints to reflect 7.4.12 as the true minimum. Fixes WordPress#240 Co-authored-by: Claude <noreply@anthropic.com>
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @claude, @sensahin. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Regenerates the content-hash after bumping config.platform.php from 7.4 to 7.4.12 in composer.json, which caused the lock file to be flagged as out of date in CI. https://claude.ai/code/session_0196NorwZgGmwBVudD4Q3eQz
Corrects the content-hash after bumping config.platform.php from 7.4 to 7.4.12. The previous hash was computed with extra config fields; this one matches Composer's Locker::getContentHash() exactly (only config.platform is included). Passes `composer validate` locally. https://claude.ai/code/session_0196NorwZgGmwBVudD4Q3eQz
Updates the baked-in platform and platform-overrides values in composer.lock to match the new >=7.4.12 requirement in composer.json. The old lock file had platform-overrides.php: 7.4, causing `composer install` to fail because 7.4 < 7.4.12. https://claude.ai/code/session_0196NorwZgGmwBVudD4Q3eQz
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## trunk #247 +/- ##
=========================================
Coverage 88.12% 88.12%
Complexity 1213 1213
=========================================
Files 60 60
Lines 3934 3934
=========================================
Hits 3467 3467
Misses 467 467
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Since composer.json enforces >=7.4.12, PHP_VERSION_ID is always >=70412 at runtime, making the 7.4.0-7.4.11 trigger_error check unreachable. PHPStan correctly flags both comparisons as always-false/always-true. The composer.json minimum version requirement is sufficient protection. https://claude.ai/code/session_0196NorwZgGmwBVudD4Q3eQz
|
Done, sorry for the mess with the composer.lock, but fixed now. |
felixarntz
left a comment
There was a problem hiding this comment.
@vyskoczilova Thank you for the PR!
Generally, this seems reasonable to me, but we need to consider how this affects WordPress Core, which relies on this package.
@johnbillion What is the exact minimum PHP version supported by WordPress now? is it 7.4 exactly? or any particular patch version of it?
|
The minimum is 7.4.0: https://make.wordpress.org/core/2026/01/09/dropping-support-for-php-7-2-and-7-3/ |
Summary
Fixes #240 — PHP 7.4.0–7.4.11 have a known PHP engine bug (bug #80126) that causes a fatal error with the covariant return type pattern used throughout this library's DTOs:
The bug was fixed in PHP 7.4.12. This PR raises the declared minimum from
>=7.4to>=7.4.12and adds a runtime guard so the problem surfaces as a clear, actionable message rather than a cryptic fatal error.Changes
composer.jsonrequire.php:>=7.4→>=7.4.12config.platform.php:7.4→7.4.12src/polyfills.phptrigger_error(E_USER_WARNING)guard at load time for PHP 7.4.0–7.4.11. This file is autoloaded via Composer'sfilesmechanism, so the warning fires on the very first request — before any DTO class is loaded and before a cryptic fatal can occur.README.mdCONTRIBUTING.mdAGENTS.mdphpcs.xml.disttestVersionvalue stays7.4-because PHPCompatibility does not support patch-level version filtering — this is correct and intentional.Notes
trigger_errorapproach (rather than throwing an exception) is deliberate: it fires early without hard-aborting, matches the WordPress-agnostic nature of the library, and follows the same conditional-check pattern already used inpolyfills.php.Closes #240
https://profiles.wordpress.org/vyskoczilova/