Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117594 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 58799 invoked from network); 25 Apr 2022 09:49:43 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Apr 2022 09:49:43 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 14F50180510 for ; Mon, 25 Apr 2022 04:24:42 -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,HTML_MESSAGE, 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-yb1-f181.google.com (mail-yb1-f181.google.com [209.85.219.181]) (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 04:24:41 -0700 (PDT) Received: by mail-yb1-f181.google.com with SMTP id r189so26427641ybr.6 for ; Mon, 25 Apr 2022 04:24:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=C7sSpmnvTDyMVYDS7pFqybPuznucnPjjdMf7Ha9Zgf0=; b=KkHPWPHe4arIGLn2AeP6CqQeCAFZVTUVZPzSEMKwF9UU2TXDZQrW9MgQSZbO7eQtgH GLeYNa5vkH3CkLsatfUyDhKX+VdowyGeK6FaUiHtj9OHyP0uKSVzWGNM5w4fSDSgtSdx H+Hmnrv1zeVhltZL3y4toZD4OGEEU3ILedTPvvBWZklQe96KMLnN0nhEx7x2qddc4B7v iO/qNSZdeCrRFNH/I8MpIVv2iDKYS94qRCo31SMvQq21sWWnNc8OTdNTvj2YGd3lpVid 66ew2A75YqwrAVOnXOw9o4imGxtGiuBWTj4IlI9H9teofy7NAZIOUbQpmeMbiiyZzJDz 2Slg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=C7sSpmnvTDyMVYDS7pFqybPuznucnPjjdMf7Ha9Zgf0=; b=iqrrYzt6sXaSLHs2aA4cKYqOcmPDzDs/eI5eEzU/3sXpHnAujDnPqqrd2g8RrHGnIX Dx5D7H1zBIeguLHPIusmNXLXXWpOyNg/Gj8fMBMyZM7lbCxZht1Vr6B4AJFaUHWoTlqY gYYSS6W9E7bezgXJBJouUY680UiUHY8kUhI+pQbn66MqKXjwlzlh/m/xshdorrQRBh7x x1JTOJiu2bbvbHUXY7mEo0DSo6FC/gvUkZwCBuUXBC4qouIT2C+rNEstZ7ew4Odml72F 6SBul/HrxNRuXJdqjwi9XS0eAC6v7ivZvp5+3CKBRm4k8WCnODgQyxd7shjP6eMfEtcT /7tQ== X-Gm-Message-State: AOAM531+pXfVgNy/GVG8tSb3o9/m4S2Q6v+V/PhOSprjAAwUKE1PLYuT KNA7Myb6JCh55OsZteA50N7wGhtBJntSj0KWMrUhT4Sbsg== X-Google-Smtp-Source: ABdhPJyq3jvp65/1eaU3bgGR6zIlJd0/50axYYbvfrcauC/G4C/oZN2w+gpFVap4UwGrsyGskb988bZ3AsrQ19AdU1c= X-Received: by 2002:a25:a148:0:b0:641:d14b:ddd3 with SMTP id z66-20020a25a148000000b00641d14bddd3mr15969061ybh.402.1650885881185; Mon, 25 Apr 2022 04:24:41 -0700 (PDT) MIME-Version: 1.0 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: <2fcee325-9ac1-8ad4-f55b-a0627c53a445@gmail.com> Date: Mon, 25 Apr 2022 13:24:32 +0200 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary="0000000000008349f405dd78d218" Subject: Re: [PHP-DEV] [VOTE] Undefined Property Error Promotion From: guilliam.xavier@gmail.com (Guilliam Xavier) --0000000000008349f405dd78d218 Content-Type: text/plain; charset="UTF-8" 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. > 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 could special case nullable, but then it's an extra rule to learn > > beyond "typed = needs to be initialized". > > I'm more inclined to the opposite: if reading an "undefined" property is > going to be an error, maybe reading an "uninitialized" one should be > too, even if you don't declare a type for it. > Are you proposing to deprecate the implicit `= null` default initializer for untyped properties? > And maybe we should think about exactly what unset() means, and which > error you're going to get after you use it - is the property "undefined" > or "uninitialized"? Currently, an untyped property becomes "undefined", > as though it never existed; but a typed property is still on the object, > but "uninitialized". Yet either way, assigning a new value brings back > the declared property, not a dynamic one with the same name: > https://3v4l.org/nClNs > 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? * "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." Regards, -- Guilliam Xavier --0000000000008349f405dd78d218--