Re: [RFC] Deprecate passing null to non-nullable arguments of internal functions
| From: | tyson andre | Date: | Thu, 03 Dec 2020 02:14:25 +0000 |
| Subject: | Re: [RFC] Deprecate passing null to non-nullable arguments of internal functions | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-112388@lists.php.net to get a copy of this message | ||
Hi Nikita,
> I've put up an RFC to make the handling of "null" arguments consistent
> between internal and user-defined functions:
>
> https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg
>
> I started an informal discussion for this change during the 7.4 cycle
> already, but decided to postpone the change at the time.
Sounds like a good idea - available open source static analyzers are much better than they were when
php 7.0.0 was released,
and php now has nullable types, union types and property types.
E.g. Phan already warns about passing null/nullable to internal functions as strictly as
user-defined functions,
partly because I'd assumed internal functions would change in the future.
https://phan.github.io/demo/?code=%3C%3Fphp%0Afunction+test%28%3Fstring+%24str%29+%7B%0A++++return+strlen%28%24str%29+%2B+strlen%28null%29%3B%0A%7D
(10MB webassembly demo)
Regards,
Tyson