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

PHP 8.1 deprecation notices #3

Merged

Conversation

ChristophWurst
Copy link

As of PHP8.1 many string functions do not accept null anymore. Therefore
more explicit null checks or alternative functions need to be used.

The errors I found are the following:

Passing null to parameter #1 ($string1) of type string is deprecated at Horde_Mail/Horde/Mail/Rfc822/Address.php#147
Passing null to parameter #1 ($string) of type string is deprecated at Horde_Mail/Horde/Mail/Rfc822/Address.php#185
Passing null to parameter #3 ($subject) of type array|string is deprecated at Horde_Mime/Horde/Mime/Headers/Element.php#145
Passing null to parameter #1 ($string) of type string is deprecated at Horde_Mail/Horde/Mail/Rfc822/Address.php#171
Passing null to parameter #1 ($string) of type string is deprecated at Horde_Mail/Horde/Mail/Rfc822/Address.php#102
Passing null to parameter #1 ($string) of type string is deprecated at Horde_Mail/Horde/Mail/Rfc822.php#651
Passing null to parameter #1 ($string) of type string is deprecated at Horde_Mail/Horde/Mail/Rfc822/Identification.php#51

I'm putting this as draft as I plan to have another look tomorrow. I'm not confident about all of the changes.

@bytestream
Copy link
Owner

bytestream commented Apr 28, 2022

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /v/lib/Horde/Mail/Rfc822/Address.php on line 155
Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /v/lib/Horde/Mail/Rfc822/Address.php on line 167
Deprecated: preg_replace(): Passing null to parameter #2 ($replacement) of type array|string is deprecated in /v/lib/Horde/Mail/Transport.php on line 211

@ChristophWurst ChristophWurst force-pushed the fix/rfc822-personal-null branch from 683ed9a to b5818be Compare May 20, 2022 11:33
@ChristophWurst
Copy link
Author

Rebased to your fork. Still some work to do.

PHP Deprecated:  preg_replace(): Passing null to parameter #2 ($replacement) of type array|string is deprecated in /home/runner/work/Mail/Mail/lib/Horde/Mail/Transport.php on line 211
PHP Deprecated:  strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /home/runner/work/Mail/Mail/lib/Horde/Mail/Rfc822/Address.php on line 155
PHP Deprecated:  strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /home/runner/work/Mail/Mail/lib/Horde/Mail/Rfc822/Address.php on line 167
PHP Deprecated:  strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /home/runner/work/Mail/Mail/lib/Horde/Mail/Rfc822.php on line 409
PHP Deprecated:  trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/runner/work/Mail/Mail/lib/Horde/Mail/Rfc822.php on line 651

@codecov-commenter
Copy link

codecov-commenter commented May 20, 2022

Codecov Report

Merging #3 (256caaa) into master (6242bb9) will decrease coverage by 0.08%.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##             master       #3      +/-   ##
============================================
- Coverage     60.88%   60.79%   -0.09%     
- Complexity      508      510       +2     
============================================
  Files            16       16              
  Lines          1153     1153              
============================================
- Hits            702      701       -1     
- Misses          451      452       +1     
Impacted Files Coverage Δ
lib/Horde/Mail/Rfc822.php 77.92% <100.00%> (ø)
lib/Horde/Mail/Rfc822/Address.php 95.23% <100.00%> (-1.20%) ⬇️
lib/Horde/Mail/Rfc822/Identification.php 87.50% <100.00%> (ø)
lib/Horde/Mail/Transport.php 69.81% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6242bb9...256caaa. Read the comment docs.

@ChristophWurst
Copy link
Author

I'm not sure what to do instead of null in \Horde_Mail_Transport::_sanitizeHeaders. An empty string? Unset the index?

@bytestream
Copy link
Owner

I think an empty string is best as that replicates the deprecated behaviour. Whether or not that's correct from a Horde perspective I'm not sure.

@ChristophWurst
Copy link
Author

The output is clean now

As of PHP8.1 many string functions do not accept null anymore. Therefore
more explicit null checks or alternative functions need to be used.

Signed-off-by: Christoph Wurst <[email protected]>
@ChristophWurst ChristophWurst force-pushed the fix/rfc822-personal-null branch from 256caaa to 366515a Compare May 23, 2022 06:27
@ChristophWurst ChristophWurst marked this pull request as ready for review May 23, 2022 06:27
@bytestream bytestream merged commit 73f5798 into bytestream:master May 23, 2022
@bytestream bytestream changed the title Fix RFC822 address nullable personal attribute PHP 8.1 deprecation notices May 23, 2022
@ChristophWurst
Copy link
Author

@bytestream thanks a lot for the merge. May I ask you to tag a new release for the latest changes on master?

@bytestream
Copy link
Owner

@ChristophWurst one step ahead of you - https://packagist.org/packages/bytestream/horde-mail

@ChristophWurst
Copy link
Author

You're the best!

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