Fix PHP 8.1+ deprecations on the payment path (number_format, jsonSerialize)#1411
Open
rcoenen wants to merge 7 commits into
Open
Fix PHP 8.1+ deprecations on the payment path (number_format, jsonSerialize)#1411rcoenen wants to merge 7 commits into
rcoenen wants to merge 7 commits into
Conversation
Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.2 to 1.16.0. - [Release notes](https://github.com/follow-redirects/follow-redirects/releases) - [Commits](follow-redirects/follow-redirects@v1.15.2...v1.16.0) --- updated-dependencies: - dependency-name: follow-redirects dependency-version: 1.16.0 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.4 to 1.16.0. - [Release notes](https://github.com/follow-redirects/follow-redirects/releases) - [Commits](follow-redirects/follow-redirects@v1.15.4...v1.16.0) --- updated-dependencies: - dependency-name: follow-redirects dependency-version: 1.16.0 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [postcss](https://github.com/postcss/postcss) from 8.4.38 to 8.5.10. - [Release notes](https://github.com/postcss/postcss/releases) - [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md) - [Commits](postcss/postcss@8.4.38...8.5.10) --- updated-dependencies: - dependency-name: postcss dependency-version: 8.5.10 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com>
…ews/assets/follow-redirects-1.16.0 Bump follow-redirects from 1.15.2 to 1.16.0 in /views/assets
…llow-redirects-1.16.0 Bump follow-redirects from 1.15.4 to 1.16.0
…stcss-8.5.10 Bump postcss from 8.4.38 to 8.5.10
…ialize) These surface on PHP 8.3 and become a fatal TypeError on PHP 9 (see mollie#1410). - TextFormatUtility::formatNumber: cast $unitPrice to float so a null amount no longer triggers the number_format() deprecation. Output is unchanged (number_format(null, ...) already yields "0"). - Add #[\ReturnTypeWillChange] to the four JsonSerializable implementations that declare no return type (Object/Payment, Object/Company, Errors/Error, ApplePay/Carrier/Carrier). The four DTOs that already return ': array' (OrderLine, OrderData, PaymentData, PaymentLine) are covariant with mixed and left untouched. The attribute keeps PHP 7.x compatibility. Refs mollie#1410 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the PHP 8.1+ deprecation notices reported in #1410. They surface on the payment/checkout path on PHP 8.3 and become a fatal
TypeErroron PHP 9, so this is a forward-compatibility fix (no behaviour change on supported PHP versions).Changes
1.
number_format(null)—src/Utility/TextFormatUtility.phpformatNumber()can receive anull$unitPrice, andnumber_format(null, …)is deprecated since PHP 8.1 and aTypeErroron PHP 9. Casting tofloat(null →0.0) preserves the current output —number_format(null, …)already yields"0"— with no behaviour change.2.
jsonSerialize()return type — 4 DTOsJsonSerializable::jsonSerialize()is declared: mixedsince PHP 8.1, so implementations with no declared return type emit a deprecation. Added#[\ReturnTypeWillChange](parsed as a comment on PHP 7.x, recognised on 8.1+) to the four implementations that declare no return type:src/DTO/Object/Payment.php(the one observed firing in PHP 8.3 deprecations in module code (number_format(null), jsonSerialize) — fatal TypeError on PHP 9 — v6.4.3 #1410)src/DTO/Object/Company.phpsrc/Errors/Error.phpsrc/DTO/ApplePay/Carrier/Carrier.phpThe four DTOs that already declare
: array(OrderLine,OrderData,PaymentData,PaymentLine) are covariant withmixedand were left untouched.Notes
#[\ReturnTypeWillChange]was chosen over a: mixedreturn type becausecomposer.jsondeclares nophpfloor (the module still targets PHP 7.x), and: mixedrequires PHP 8.0+.nullamount reachesformatNumber()in the payment flow, but the cast removes the deprecation/TypeErrorregardless.php -lis clean on all changed files.Refs #1410
🤖 Generated with Claude Code