Re: Allowing NULL for some internal functions
| From: | Guilliam Xavier | Date: | Mon, 28 Feb 2022 17:35:09 +0000 |
| Subject: | Re: Allowing NULL for some internal functions | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-117164@lists.php.net to get a copy of this message | ||
On Mon, Feb 28, 2022 at 5:41 PM Dik Takken <dik.takken@gmail.com> wrote:
>
> In my view, consistency between internal and userland functions brings a
> lot of value, and not only for the language itself. As soon as internal
> and userland become fully consistent it will become a lot easier to
> write "internal" functions in PHP rather than C. Not only will that make
> developing the standard library easier, it may also make the optimizer
> and JIT compiler more effective. The more consistency the better.
>
Yes, and we see two possible ways to make them consistent w.r.t. handling
of null argument passed into scalar parameter:
1. implicit coercion by default, error with strict_types=1
2. error (independent of strict_types)
AFAIK, internal functions have been doing 1 since like forever, but PHP 7.0
chose 2 for userland functions when introducing scalar parameter type
declarations (see my previous message for history) and PHP 8.1 continued in
that direction by deprecating 1 for internal functions (and planning to
change them to 2 in PHP 9.0).
Call me devil's advocate, but is it too late to discuss revisiting past
decisions and consider changing direction towards 1 for userland functions
(esp. in implications of BC impact)?
Regards,
--
Guilliam Xavier