Re: Disable autovivification on false
| From: | Claude Pache | Date: | Tue, 25 May 2021 17:13:26 +0000 |
| Subject: | Re: Disable autovivification on false | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-114597@lists.php.net to get a copy of this message | ||
> Le 25 mai 2021 à 18:23, Kamil Tekiela <tekiela246@gmail.com> a écrit :
>
> Hi Internals,
>
> I'd like to start a discussion on the following RFC
> https://wiki.php.net/rfc/autovivification_false
> Particularly, I am looking for opinions on whether this behaviour should be
> left alone, should be disabled on false, or should be disabled on null and
> false, and left only for undefined variables.
>
> Autovivification is very useful in PHP, especially with multidimensional
> arrays and loops. However, the question is should we allow it on false and
> null values going forward.
>
> Kind Regards,
> Kamil Tekiela
Hi,
* IMO, null and undefined should be treated the same way, because for many purposes, they are not
distinguished (e.g., isset() and ??). In general, I’m setting something to null when I want to
avoid an “Undefined symbol” notice, I am sure it is not a bug, and I don’t want to scatter my
code with
isset() or ?? checks.
* In any case, the removing of the autovivification behaviour MUST be preceded by a period of
deprecation notices.
—Claude