Re: NULL Coercion Consistency
| From: | Mel Dafert | Date: | Fri, 08 Apr 2022 17:54:59 +0000 |
| Subject: | Re: NULL Coercion Consistency | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-117502@lists.php.net to get a copy of this message | ||
On 8 April 2022 19:34:52 CEST, Craig Francis <craig@craigfrancis.co.uk> wrote:
>Hi,
>
>I've written a new draft RFC to address the NULL coercion problems:
>
>https://wiki.php.net/rfc/null_coercion_consistency
>
>This is due to the result of the Allow NULL quiz:
>
>https://quiz.craigfrancis.co.uk/
>
>14 votes for Fatal Type Errors irrespective of
strict_types=1;
>13 votes for NULL coercion when not using strict_types=1;
>8 votes to update some parameters to allow NULL;
>
>I appreciate some want to force strict type checking on everyone, but I
>want to make sure we have this properly documented, with names, and
>explanations.
>
>Breaking changes should be justified - if they aren't, they only
>make upgrading difficult and frustrating (bad for security).
>
>Craig
Hello,
While the RFC extensively documents the problem space, it's rather short on what
exactly it proposes.
In particular, does this propose changing user-defined functions under
strict_types=0 to accept null for scalar types?
Eg., this will be allowed (under strict_types=0):
```
function x(string $y, int $z) {
...
}
x(null, null); //no error, no warning
```
Regards,
Mel