Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117600 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 81006 invoked from network); 25 Apr 2022 14:44:35 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Apr 2022 14:44:35 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 80B741804AB for ; Mon, 25 Apr 2022 09:19:37 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 ; Mon, 25 Apr 2022 09:19:37 -0700 (PDT) Received: by mail-wm1-f41.google.com with SMTP id ay11-20020a05600c1e0b00b0038eb92fa965so12839739wmb.4 for ; Mon, 25 Apr 2022 09:19:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to:content-transfer-encoding; bh=TTx9YJyWjmIG3J/uyDF9H6KZ8lxjEF0mlO9GUV3mnq4=; b=Y5dGv1VjBjhXjlfwFiCuXQNVcY4vPEKz9NSaz8hQyDdGvEMAQ3J/RPmfzazseW7qui qI/mnBJj9a5dZxxblNvePy3KaHNVSrEEpqo1O9w+jsvv7UQl5W0S9ZmBxA+rL07l6zR6 gHzkYMQgu/RYy6owo1qHc4ZVBY9e9A2aN1g+x3zchSs4qwPxrSLxnj7B/BjjXBTtrnzq kc7Gw+M3zPebiAC/SlCRlayK6GimH2mvLT5EuVJS1t1cOe2QUP73pqOn21n5m8RX8Gfa zk3QG982p2tJOKKfVLdsW2hqu22lX8WslAewZApRmYamXPzhbicJOxUynqcbUZFSvnzU jMnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=TTx9YJyWjmIG3J/uyDF9H6KZ8lxjEF0mlO9GUV3mnq4=; b=kSpkkzMZ9lykEl2gimkAVEN3O6osUfKoUBGxB3XSpEXx8ZfJj+78bXGAhCWpTiUh4p NCEX2Uu44zpGD/zhAAsm8OuHfvEE75DZ1oAHhYwIi30YwLK6s1Toua/gAFM3Qmnd5EH4 rmmpoxR4tmu9HrGu3cQ2aG/l6r79EM5XZujzTeUu8mlzO/XHDPsnsimvhqGRCbeBUqDI +tJaGrmbBZsaX3txerRbNfVdm+Ym006C9HCTYq7ZQLXaj2PaL22OuXkcNSyqsxzCZtqj sRolzOyfLJrgjw0UYe51Lmn08JyCj6iZ8yB9FFE9ujFDSg0WC0qmRC3rHPTys4KgCQEt yQfA== X-Gm-Message-State: AOAM531uF6nYFggsNKlrubmmnkHyGxTuAjVrxzxYBZlID1IqrjScd8Fh 2MisyywdZR2CCtm4hklcfIFKnlJWy1s= X-Google-Smtp-Source: ABdhPJyNE2eueUoO+4u0Y2AIW1FH6fHB0IyV+GyupB8GZlaZvJzmba86OHY61oiqLmmqX7uAfKwOVQ== X-Received: by 2002:a05:600c:3502:b0:393:f169:b273 with SMTP id h2-20020a05600c350200b00393f169b273mr333775wmq.180.1650903575791; Mon, 25 Apr 2022 09:19:35 -0700 (PDT) Received: from [192.168.0.22] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.googlemail.com with ESMTPSA id e4-20020a5d6d04000000b0020a8bbbb72bsm11298266wrq.97.2022.04.25.09.19.34 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 25 Apr 2022 09:19:34 -0700 (PDT) Message-ID: <2bf2433e-2a4d-7523-7633-0e67a22a0c26@gmail.com> Date: Mon, 25 Apr 2022 17:19:33 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Content-Language: en-GB To: internals@lists.php.net References: <6261d073.1c69fb81.a42c.d7cfSMTPIN_ADDED_MISSING@mx.google.com> <6262e219.1c69fb81.f1cd4.6ff5SMTPIN_ADDED_MISSING@mx.google.com> <6263147d.1c69fb81.c372a.2e76SMTPIN_ADDED_MISSING@mx.google.com> <2fcee325-9ac1-8ad4-f55b-a0627c53a445@gmail.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [VOTE] Undefined Property Error Promotion From: rowan.collins@gmail.com (Rowan Tommins) On 25/04/2022 12:24, Guilliam Xavier wrote: > Hi Rowan, > > (...) Also, there's this non-standard class called >> "stdClass", which unlike standard classes, you can read and write any >> property you like without declaring it, > > Better reordered "write and read" I think. Yes, like associative arrays, > stdClass is "dynamic" by design. Indeed, and if that was the only exception, it would be reasonable; it's when you pile it on top of all the other rules that it starts making people sad. >> and even if you use unset(), >> you'll never get an error. >> > That's not true, e.g. given `$o = (object)['foo' => 1]; $o->bar = 2;` then > `unset($o->foo, $o->bar);`, trying to read `$o->foo` or `$o->bar` will both > cause an error (like for `$o->qux`); or I'm misunderstanding you? You're right, I was mis-remembering; the RFC explicitly says that this will error. > Are you proposing to deprecate the implicit `= null` default initializer > for untyped properties? Yes. > Thanks for the recap. For untyped properties, that's the historical > behavior. For typed properties, that's explained in > https://wiki.php.net/rfc/typed_properties_v2#uninitialized_and_unset_properties > *. What's the issue? The issue is that for new users, saying "that's the historical behaviour, you just have to learn it" is not very helpful. > * "If a typed property is `unset()`, then it returns to the uninitialized > state. While we would love to remove support for the unsetting of > properties, this functionality is currently used for lazy initialization by > Doctrine, in combination with the functionality described in the following > section." I think both you and Mark misunderstood my point in bringing this up - I'm not complaining about the ability to call unset(), I'm complaining that it behaves differently depending how the property was declared. Look at how the untyped property behaves in this example: https://3v4l.org/nClNs The property disappears from var_dump(), but is not actually deleted from the object, as seen by it still being private when assigned a new value. Given that we have the magic "uninitialized" state, and we're proposing to make reading an unset property an error, it would make more sense for it to show as '["untyped":"Foo":private] => uninitialized(mixed)' Regards, -- Rowan Tommins [IMSoP]