Closed jcvignoli closed 1 year ago
well it might be better to check if $dir['role'] == null up front?
Yes, much cleaner 😃
Solved in v7.4.0+
To me it sounds strange to cast null to string? If you up front check if $dir['role'] == null the whole string_replace could be bypassed.
It is a matter of opinion i guess
Converting/casting null
to scalar types is what PHP did internally until they deprecated it in PHP 8.1 so it's a backport of how it used to behave. Some projects use them but it's better to rewrite your application to correct types as PHP are becoming a more strict language. Which we can't use as this project supports PHP 5.6+.
PHP RFC: Deprecate passing null to non-nullable arguments of internal functions
@jreklund thanks for explaining, i didn't know this!
Just updated to PHP8.1 and found a deprecated code:
Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in vendor/imdbphp/imdbphp/src/Imdb/Title.php on line 1645
On line 1645 in Title.php, changing
$dir['role'] = str_replace(' / ...', '', $dir['role']);
by$dir['role'] = str_replace(' / ...', '', $dir['role'] ?? '');
did the trick.