How to use default value when `null` is given for a nullable function parameter?

Viewed 13711

In PHP 7.1 when the following function is called:

private function doStuff(?int $limit = 999) { }

with syntax like so:

doStuff(null);

the value of $limit becomes null. So I guess it can be said that the value of $limit was explicitly set to null.

Is there any way to overcome this? I.e. when a null value (i.e. the lack of a value) is encountered use the default, whether it is implicit or explicit?

1 Answers
Related