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

Fix php8.1 null parameter #469

Merged
merged 1 commit into from
Sep 20, 2022
Merged

Fix php8.1 null parameter #469

merged 1 commit into from
Sep 20, 2022

Conversation

bahirul
Copy link

@bahirul bahirul commented Sep 17, 2022

PHP Deprecated

Passing null to parameter deprecated on PHP 8.1

PHP Deprecated : trim() : Passing null to parameter #1 ($string) of type string is deprecated.

This happens when the default value for the variable is null.

Possible Solution

We can simply cast the variable to string to fix the issue.

-trim($v);
+trim((string) $v);

-ltrim($v);
+ltrim((string) $v);

-rtrim($v);
+rtrim((string) $v);

This solution also used in symfony. Please see this.

@sihar sihar merged commit e042ccb into mdmsoft:master Sep 20, 2022
@sihar
Copy link
Collaborator

sihar commented Sep 20, 2022

I have checked your solution and your link to symfony.
Thanks @bahirul

@bahirul bahirul deleted the fix-php8.1-null-parameter branch September 20, 2022 03:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants