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: fix "passing null to non-nullable" deprecation notice #689

Conversation

jrfnl
Copy link
Contributor

@jrfnl jrfnl commented Aug 10, 2021

As of PHP 8.1, passing null to non-nullable arguments of PHP native functions is deprecated.
Ref: https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg

The SimplePie_Enclosure::get_extension() returns the file extension as a string or null.

In the SimplePie_Enclosure::get_real_type() method, the return value of a call to the get_extension() method was directly passed on to the PHP native strtolower() function, leading to the PHP 8.1 strtolower(): Passing null to parameter #1 ($string) of type string is deprecated deprecation notice.

This small change fixes this issue without BC break.

This is covered by 36 of the existing tests in the OldTest class.

As of PHP 8.1, passing `null` to non-nullable arguments of PHP native functions is deprecated.
Ref: https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg

The `SimplePie_Enclosure::get_extension()` returns the file extension as a string or `null`.

In the `SimplePie_Enclosure::get_real_type()` method, the return value of a call to the `get_extension()` method was directly passed on to the PHP native `strtolower()` function, leading to the PHP 8.1 `strtolower(): Passing null to parameter simplepie#1 ($string) of type string is deprecated` deprecation notice.

This small change fixes this issue without BC break.

This is covered by 36 of the existing tests in the `OldTest` class.
@jrfnl jrfnl force-pushed the feature/php-8.1-fix-passing-null-to-non-nullable branch from 08ee8ce to 8b0e86f Compare August 14, 2021 02:33
@mblaney mblaney merged commit f58a237 into simplepie:master Aug 14, 2021
@jrfnl jrfnl deleted the feature/php-8.1-fix-passing-null-to-non-nullable branch August 14, 2021 02:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants