Re: Disable autovivification on false
| From: | Sara Golemon | Date: | Tue, 25 May 2021 19:47:33 +0000 |
| Subject: | Re: Disable autovivification on false | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-114599@lists.php.net to get a copy of this message | ||
On Tue, May 25, 2021 at 11:23 AM Kamil Tekiela <tekiela246@gmail.com> wrote:
> 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.
>
>
I agree it's useful, and should 100% not be killed on undef. There is
doubtless a mountain of code in WordPress plugins alone which relies on
this, not to mention other frameworks and libraries.
As for
false and null, I think it's reasonable to kill these (with a
deprecation period) in a major version (e.g. 9.0). It might also be
reasonable to only kill this behavior when strict_types is enabled.
Essentially it would enforce making the array type accessors strict about
operating on arrays. Would still need a deprecation period to go with
that, but it would be less-rough on migrations of legacy codebases.
-Sara