Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114601 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 2947 invoked from network); 25 May 2021 20:16:32 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 May 2021 20:16:32 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E9DBE180507 for ; Tue, 25 May 2021 13:27:53 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from malamute.woofle.net (woofle.net [74.207.252.100]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 25 May 2021 13:27:53 -0700 (PDT) Received: by malamute.woofle.net (Postfix) with ESMTPSA id 523821F253; Tue, 25 May 2021 13:27:51 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.80.0.2.43\)) In-Reply-To: Date: Tue, 25 May 2021 13:27:50 -0700 Cc: PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: <7DC82988-16E1-4228-BF94-46E633BD116E@woofle.net> References: To: Kamil Tekiela X-Mailer: Apple Mail (2.3654.80.0.2.43) Subject: Re: [PHP-DEV] Disable autovivification on false From: dusk@woofle.net (Dusk) On May 25, 2021, at 09:23, Kamil Tekiela 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. It seems to me there are two different sorts of autovivification which = can happen. (They may actually be the same thing under the hood, but = they feel different to me.) One is autovivification within an array, e.g. $x =3D ["b" =3D> null, "c" =3D> false]; $x["a"][] =3D 1; // from unset $x["b"][] =3D 2; // from null $x["c"][] =3D 3; // from false The other is autovivification on values outside arrays, e.g. $b =3D null; $c =3D false; $d =3D new stdClass(); $a[] =3D 1; // from unset $b[] =3D 2; // from null $c[] =3D 3; // from false $obj->a[] =3D 4; // from unset on an object property, same idea (The same behavior occurs in each case if an explicit key is used = instead of [].) =46rom my perspective, the latter is much more concerning than the = former. Adding dimensions to an existing array feels like less of a = type-correctness violation than calling an entire array into existence = where a non-array value (or no value at all) existed before.=