Skip to content

PHP 8.1: fix "passing null to non-nullable" deprecation notice#689

Merged
mblaney merged 1 commit intosimplepie:masterfrom
jrfnl:feature/php-8.1-fix-passing-null-to-non-nullable
Aug 14, 2021
Merged

PHP 8.1: fix "passing null to non-nullable" deprecation notice#689
mblaney merged 1 commit intosimplepie:masterfrom
jrfnl:feature/php-8.1-fix-passing-null-to-non-nullable

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.

2 participants