fix(license): Cast return values in CustomerDataTrait for PHP 8.5 strict_types#8127
Open
theMosaad wants to merge 1 commit into
Open
fix(license): Cast return values in CustomerDataTrait for PHP 8.5 strict_types#8127theMosaad wants to merge 1 commit into
theMosaad wants to merge 1 commit into
Conversation
`get_customer_key()` and `get_customer_email()` declare `string` return types under `declare(strict_types=1)`, but `Options_Data::get()` and `rocket_get_constant()` return `mixed`. On PHP 8.5 this throws a `TypeError` when the stored value is not strictly a string. Add explicit `(string)` casts to both return branches of both methods. This is backwards-compatible — casting a string to string is a no-op. Fixes wp-media#8126
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.
CustomerDataTrait::get_customer_key()andCustomerDataTrait::get_customer_email()declarestringreturn types in a file withdeclare(strict_types=1). Both methods return values fromOptions_Data::get()androcket_get_constant(), which returnmixed. On PHP 8.5, when the stored value is not strictly a string, this throws a fatalTypeError.This adds explicit
(string)casts to all four return branches. The casts are backwards-compatible — casting a string to string is a no-op on older PHP versions.Fixes #8126