Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117487 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 23207 invoked from network); 6 Apr 2022 15:57:26 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 6 Apr 2022 15:57:26 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4B1AD18053E for ; Wed, 6 Apr 2022 10:27:43 -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-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (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 ; Wed, 6 Apr 2022 10:27:42 -0700 (PDT) Received: by mail-pf1-f176.google.com with SMTP id y10so3070374pfa.7 for ; Wed, 06 Apr 2022 10:27:42 -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=43g+Pu8kejmOJl4QQ8ZiPcuKjItV/PA7fzDrDirWgFs=; b=ZBSXGuPc6q39xmYJ48l0wy3r0gz0nOtcM7FEgdfiZVfiWS5aUcUhObl4yyl/xm4qCf hPuxoJ/oO0JuHu2eFnqcs4wR78BUeMv5qWRVZ+1xjAZfeIuNgDoen43R9taxNP1wURe3 40EiEAaMIPKj4clwC1dPsDKy6MIZVTLn90w3m/6yu2BseC/uj2PqUhLgsEgR4Qxri14a 2jFXEo4TuHie9HYsDpAjSRpRbsPDnqKe9YQFNq+OJNhdnw1zlWxhzj8HGntjKQmHQRi6 X5EZSsYgsMdoKPGZHQ4zGmOwj24bbKzSnnLhLeawAzSHgtmUGK7KiKHtKz3t4tGFA5Cj wt4A== 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=43g+Pu8kejmOJl4QQ8ZiPcuKjItV/PA7fzDrDirWgFs=; b=dro4m7Tpfl7Dfw2OtYoqPAd7RRsssJuqamBdsxMsrvQtVxPbnfgD1Xeb1QjGzpUyH4 zeXdT0INZ2zH2PFsaRoDutwd4bqSJZpgLRGKIXymRV8K/WI9yu+pDaV3yyk6z9DRVk7n 4zT0OlHiK/MR2ykuEqIhM5fkESYRiBqL7KuVL03kcb1Gfw9YK+lA02AjaxXGQ0m5xvnk RK1LGJU7Qcnr8/ojD37xHcBEdC1CdfOdx1LjSs/iw7lcGlsU0jWlrRa/XlQLl9tUBV3D eG0kjXgXEBAz+LWb7TjRxgFKeX3RAhkkQmIEONX1lRexUr0Qdsw5ReZqcIM9KsaTwBgY jgjw== X-Gm-Message-State: AOAM532Qtey6OVigGiMybl6OnjvnN0U4kFwxKUczc2WyeLgX54TyJyvY 9xz5SAWvHhHVNG8Wu9pGj0T5BWpzrXSosq8DmhoKcfMMAcw= X-Google-Smtp-Source: ABdhPJz/bA/xZlkGaOod6AKGRgNuH9flHp1A5kZgJ26WlmdxGVsTTAx3z6eytaDjneUCW4syXer5QXlaZqsPTdkzJbE= X-Received: by 2002:a63:31cb:0:b0:399:1d7c:287d with SMTP id x194-20020a6331cb000000b003991d7c287dmr7927426pgx.522.1649266061730; Wed, 06 Apr 2022 10:27:41 -0700 (PDT) MIME-Version: 1.0 References: <624d81b4.1c69fb81.eae57.b277SMTPIN_ADDED_MISSING@mx.google.com> In-Reply-To: Date: Wed, 6 Apr 2022 18:27:30 +0100 Message-ID: To: internals Content-Type: multipart/alternative; boundary="000000000000bfe7f305dbffad78" Subject: Re: [PHP-DEV] [RFC] Undefined Property Error Promotion From: rowan.collins@gmail.com (Rowan Tommins) --000000000000bfe7f305dbffad78 Content-Type: text/plain; charset="UTF-8" On Wed, 6 Apr 2022 at 14:37, Guilliam Xavier wrote: > First sentence of the introduction: "Undefined properties are those that > have not yet been defined either by the presence of a property declaration, > or by adding them to the properties hashmap through direct assignment, or > by having them assigned by an internal function such as json_decode." > `$obj->prop` alone doesn't define the property "prop", but `$obj->prop = > whatever` does. > I missed the implications of this at first too; maybe some examples would be useful? The more I think about it, the more different scenarios there are here, some of which are more obvious than others: 1) Reading a property that is not listed in a class definition, and has never been written to 2) Reading a property that is not listed in a class definition, but HAS previously been assigned to 3) Reading a property that IS listed in the class definition, but has been "removed" with unset() 4) Reading a property that is listed in the class definition, but has no default value, and has never been assigned For each of these, we could consider the behaviour: a) on an instance of stdClass b) on a class with the AllowDynamicProperties attribute c) on a class with neither Of these: * Case 1 seems like the most obviously in scope of the proposal. * Case 2c would be impossible, because assigning to the property would already have given an error. 2a and 2b are the open question that's already been mentioned. * Cases 3 and 4 already throw an error for *typed* properties, which track the special "uninitialised" state, but for untyped properties case 4 does not currently raise a Warning. As with the previous RFC, I think this should be an opportunity to define the consistent behaviour we want, rather than just looking at what previous versions did. Regards, -- Rowan Tommins [IMSoP] --000000000000bfe7f305dbffad78--