Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117956 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 59572 invoked from network); 15 Jun 2022 22:06:47 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 15 Jun 2022 22:06:47 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1536C1804C4 for ; Wed, 15 Jun 2022 16:54:38 -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.0 required=5.0 tests=BAYES_05, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, 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-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) (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 ; Wed, 15 Jun 2022 16:54:37 -0700 (PDT) Received: by mail-ed1-f42.google.com with SMTP id x5so18388257edi.2 for ; Wed, 15 Jun 2022 16:54:37 -0700 (PDT) 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:cc; bh=HLeG0uv/sNFRhCrxOP54tYgWCKUXwBHCpy+24zIrviM=; b=lMyo6+1dKCxn+q+9JRHZhrrC7b6G5IN1U3OA62x6kAXxDPWdwdt9ENYIfWnxNFMY0u +ge7+rQGcX1UT5q73EXYZPwhWLX2i+i1P+9zRwwEmujoQY3ZYmf0nEQ6J8YGZxvPpuvc Vn5FFIDzOBjqc8cN/vdmfyXuQSPzwadBBYbzMct6S+Qd31KL3ngII0THEQwoUwz0VtJT Ln75P4rIUaDLF1RU1SZp/pDzhVV9VvbEkGY9PBRAzdZdPg2RBgI+7wwYXhEloMh1+mTg wnSq9AtoWpaDarN147SILeD2+71jkL0HshvIUFKivISv5uusIpoCdneHe3IWaiVMFXLQ wPXg== X-Gm-Message-State: AJIora9+yI9T/JO0xnu5oklLcpp0vfqfOg5OyAUlaQVX61dBwFyP/mNL ASihAY/G5sTeSLdOF8EUF8hn7je0S3TIaFgy X-Google-Smtp-Source: AGRyM1ulU2rr1ID5PrwDVlqoMPoRqcdYAqnCpd0cJebAlc5pfkt8avE0It+Hm/28VlmBOmFJ53afTA== X-Received: by 2002:a05:6402:380a:b0:435:2019:52ab with SMTP id es10-20020a056402380a00b00435201952abmr2966806edb.44.1655337275667; Wed, 15 Jun 2022 16:54:35 -0700 (PDT) Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com. [209.85.128.44]) by smtp.gmail.com with ESMTPSA id i24-20020a05640200d800b0042dcac2afc6sm466658edu.72.2022.06.15.16.54.34 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 Jun 2022 16:54:35 -0700 (PDT) Received: by mail-wm1-f44.google.com with SMTP id z9so7088655wmf.3 for ; Wed, 15 Jun 2022 16:54:34 -0700 (PDT) X-Received: by 2002:a7b:c4cb:0:b0:39c:35b3:e8c1 with SMTP id g11-20020a7bc4cb000000b0039c35b3e8c1mr12756880wmk.183.1655337274690; Wed, 15 Jun 2022 16:54:34 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 16 Jun 2022 08:54:23 +0900 X-Gmail-Original-Message-ID: Message-ID: To: =?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?= Cc: Ilija Tovilo , PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [RFC][Under discussion] Fetch properties in const expressions From: sji@sj-i.dev (shinji igarashi) Hello, Ilija, Alex, > Yes, that would work fine. Thanks for the answer! I am not opposed to this behavior, but it might be better to mention it in the RFC. Unlike Enums, an object in a constant can have mutable state, so the result depends on when the constant expression is executed. If it is difficult or doesn't have the benefit to determine the timing, it would be better to clearly state that the timing of the execution of such constant expression is undefined for now. It is also an understandable behavior to prohibit the use of normal objects in the property fetching in constant expressions because of the difference in mutability between Enum and other objects. > That would mean it would not be supported for > - class constant initializers > - instance property initializers > - static property initializers The new in initializers RFC doesn't explicitly mention the fact that it allows class constants having objects via global constant, but it's already doable in PHP 8.1. class A {public int $i = 42;} const BARE_CONSTANT = new A; class B { const ClassConstant = BARE_CONSTANT; } echo B::ClassConstant->i; Thanks! -- Shinji Igarashi