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

Fixed null to string warnings in MimePart->getContentType() #199

Merged
merged 2 commits into from
Jan 5, 2023

Conversation

zacek
Copy link

@zacek zacek commented Oct 11, 2022

MimePart::getContentType() applies strtolower() on the result of getHeaderValue(). However, this result can be null even though the default value is provided as the default value is not used if the header is present but empty:

Content-Type:

In such cases, the result is null and PHP 8.1 complains:

strtolower(): Passing null to parameter #1 ($string) of type string is deprecated

My fix applies the default value even if the header is present but empty as in the example above.

Copy link
Contributor

@phpfui phpfui left a comment

Choose a reason for hiding this comment

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

Since this library currently supports PHP 5.4 (unfortunately), you should change this to

return $header->getValue() ? : $defaultValue;

@zbateson
Copy link
Owner

zbateson commented Jan 5, 2023

Wonderful, thank you!

@zbateson zbateson merged commit a08e5e5 into zbateson:master Jan 5, 2023
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.

None yet

3 participants