Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] Fix deprecation issue with translator #42216

Merged
merged 1 commit into from
May 2, 2022

Conversation

driesvints
Copy link
Member

This fixes an issue where a translation param was null and triggers a deprecation warning in PHP 8.1. On lower PHP versions, the parameter is simple added as an empty string.

See #42204

@driesvints driesvints changed the title Fix deprecation issue with translator [8.x] Fix deprecation issue with translator May 2, 2022
@@ -218,8 +218,8 @@ protected function makeReplacements($line, array $replace)
$shouldReplace = [];

foreach ($replace as $key => $value) {
$shouldReplace[':'.Str::ucfirst($key)] = Str::ucfirst($value);
$shouldReplace[':'.Str::upper($key)] = Str::upper($value);
$shouldReplace[':'.Str::ucfirst($key ?? '')] = Str::ucfirst($value ?? '');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think keys can ever be null?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only fixed the behavior that was previously in place. In any PHP version before 8.1, if null was used as a replacement it'd be casted to a string. Since PHP 8.1 throws a deprecation for this, we'll need to make sure to do this ourselves.

We can't change the behavior of handling null on 8.x or 9.x as that'd be a breaking change.

@taylorotwell taylorotwell merged commit f6e9f54 into 8.x May 2, 2022
@taylorotwell taylorotwell deleted the fix-translator-deprecation-2 branch May 2, 2022 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants