Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117846 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 89725 invoked from network); 2 Jun 2022 10:33:08 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 2 Jun 2022 10:33:08 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id EE3411804AA for ; Thu, 2 Jun 2022 05:17: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=-0.2 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, 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-io1-f48.google.com (mail-io1-f48.google.com [209.85.166.48]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 2 Jun 2022 05:17:37 -0700 (PDT) Received: by mail-io1-f48.google.com with SMTP id i9so4598587ioa.6 for ; Thu, 02 Jun 2022 05:17:37 -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 :content-transfer-encoding; bh=+wbIUytz8+IZ/ASLZPTOsKxEdksc+neWuMVZZLSxgRI=; b=oglJNBNyNACGK48R1g2gmEkGQr9QujDQBJN11nUZuTisbpBnNeITAcve41o19dI7FO xSyBNeY4fAlrBMRH4Ga22uezqfyuCfmGvgCoM6jiGV+F8SupxIAbUGsH+Hw5au4BHgr8 Ry4iOzRU1IWpyrod6T4HEdno8OOlTKgrtBzOIUnFqTJMZ+XOmBYg44btDtv5QiEG4xDr Ei92qHa56pfS+6eRSLy3Hh8jQRshOHJkPlUlfVQfJH9c8YUw1tWkf8yJoicbLwy/HleA nS6lItn4BfOS9E9CzW2nvU3AN/6xQQAU1zh9oeoTKvSXYWAb7E2f/khxRtEpWc4gjVpa S0jw== 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:content-transfer-encoding; bh=+wbIUytz8+IZ/ASLZPTOsKxEdksc+neWuMVZZLSxgRI=; b=q23V625ULew4U9Leb+bYwXO+fvpyKxH7J1vouZoazMaXg6Tlk/LL5+oKxNQp1ljXHw KTLVdxLmfNcq1LpsQPGj5hfFJTzqvA1YSONkTmC9YpHBcUxRUEdCTEURR/iJ03t+kD56 WKjb9DVNjX1GBGg9vG57CyGqjCv1F7eJd5WmzLfG+m+rJFeF1Wj7MhGDB+8LtE2Mbcrf 49/4Ap4KwXO3wWINlyLW7PnJTfaoxe4wms0bfRJll3BJ0S4JcLsE5cO941uYAvjcyD9j sJvZdLB4b9XYk3ZnYy86jrAkAnTQc0PXQvnbHld9RurfItDovlZvZf8HCPmvfzghVwWI VpdA== X-Gm-Message-State: AOAM53270fPXPWsZXYZ6l/fJpAthkvnetr+anSA1BVqw2IfonKuHeUcb p/t4YdlSDyICWvx1div/ehf+Tqk0m9kNfbPhGszT8wSoH6C/Hg== X-Google-Smtp-Source: ABdhPJz8U2KiAj8V7tI/ijWsFLdHYbxS0t1QrWpL/OuOMDOEj2dfHvIfkYIvBag5ObbyDiyasD6Vd9g2TCSmMY/fctE= X-Received: by 2002:a6b:ed0f:0:b0:657:b1ff:be52 with SMTP id n15-20020a6bed0f000000b00657b1ffbe52mr2303668iog.34.1654172256593; Thu, 02 Jun 2022 05:17:36 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 2 Jun 2022 14:17:25 +0200 Message-ID: To: PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC][Under discussion] Fetch properties in const expressions From: tovilo.ilija@gmail.com (Ilija Tovilo) Hi Nikita > This looks like a reasonable addition. > > Could there be any expectation that if -> works, ?-> does as well? Possibly. The implementation was simple enough so I'll add support for completeness. --- Hi C=C3=B4me > It is not clear to me why this allows using -> on enums but not on other = objects. The RFC *does* allow using -> on all objects. From the RFC: > As mentioned, the primary motivation for this feature are enums. However,= the > implementation for supporting new is identical and I don't believe > arbitrarily restricting how -> can be used in this context makes sense. > Can you clarify why the following is not allowed: > > > $a =3D new Thing(); > > class C > { > protected $b =3D $a->var; > static $staticobj =3D new Thing(); > function f($p =3D self::$staticobj->var) {} > } `protected $b =3D $a->var;` is not allowed because there can't be local variables in the context of context expressions. `function f($p =3D self::$staticobj->var) {}` is not allowed because static variables aren't supported in constant expressions. Your examples would already fail today without ->. Ilija