
So you have some random null values passed over to internal PHP function for non-null params? Well you are in trouble in PHP 8.1 and even more trouble when PHP 9 would pop in.
This change synchronizes the behavior of internal functions, by throwing a deprecation warning in PHP 8.1, which will become a TypeError in the next major version.
var_dump(str_contains("foobar", null));
// Deprecated: Passing null to argument of type string is deprecated
If
nullis passed to an argument of an internal function,- the argument is not nullable,
- the argument accepts at least one scalar type (one of
bool,int,float, orstring), - coercive typing mode is used, i.e.
strict_types=1is not enabled,
then
- in PHP < 8.1 the null value will be silently coerced to either
false,0,0.0or“”. - in PHP >= 8.1 a deprecation error is thrown, but the value is still coerced and the call still takes place.
- in PHP >= 9.0 a
TypeErroris thrown, consistent with the behavior of user-defined functions.
More about PHP 8.1
Read about all PHP 8.1 features and changes in here.