Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117947 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 40470 invoked from network); 14 Jun 2022 14:26:05 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 14 Jun 2022 14:26:05 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8A2BC1804C4 for ; Tue, 14 Jun 2022 09:13: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.7 required=5.0 tests=BAYES_05,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-il1-f177.google.com (mail-il1-f177.google.com [209.85.166.177]) (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 ; Tue, 14 Jun 2022 09:13:37 -0700 (PDT) Received: by mail-il1-f177.google.com with SMTP id y17so6900664ilj.11 for ; Tue, 14 Jun 2022 09:13: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; bh=tZiGx51mWXkQueYrLYy3XFLGgcVN7EACSuEZnI2VNe0=; b=ix37aIor5yVexP3elbb5zCB8zxfqkMir00KefomDDRipuazUpMj6Fow64vW509MIIf 6Q/ClOXOrIVMMc7Ds4hFeWVfijLB43LUBS2ljRuVs7dD9fELBkruS4L8tN3Q64OZF4uG AvLM6zwdPtrw4/A7GVabwArzFLhnuSbkSmrXa7NZS8WbMGm8EVcsBCwmmTUbiB4qp4Q8 D9Wqtr82R+NzamhFADG+lZ8I8lFYrTOHgjczMpEm4ZCjKxqv/djxLO3jamBajWlWUWRV cD3CPjIHfaUflM/jrJyWTLqhSnDpoUaRkaUoLuNvkl208QgLj/hDtEXpNavWveCSq9xN 6Srw== 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=tZiGx51mWXkQueYrLYy3XFLGgcVN7EACSuEZnI2VNe0=; b=pQbqp+ZMC7rvK4Rmnfc0qI9CY5OmVdt65g7mEQep4ZAMLh7wt7wCwEHbRECNZO+qbk OvJ68C8Do5ZlTVqYF46v+HtVS2U8LSSEQy4ZznovKllR6VQYy+qSzBakN6mv6AajbK6+ hBarFHeoae+CQwUprve180qFqhmTdJQMQaXxnjfvyjNNVMOatekPXzyyiYKqMQDZfo1t 805vJyJyGaKWn4EEMLqjHtn4uf0s35J+l0Xejovj6bsj2liHO71teF8ezyvRwx4g7Z3a WE0VatyC+NSYhAwvWLBP8Ld33ZL6Jghm/0exqj4/UUB+SKKnQK5LUQano5VKRcHqlfr2 +yDg== X-Gm-Message-State: AJIora9FiaaXxEbkQT4unmey5jZoUJkrF4DnYl/TgZ34rXhM7J9BZBYw n1lbXqYrmbx+33EhLTjVQesJszp0Ywu1JM2tcNxbhEH2/33OxA== X-Google-Smtp-Source: AGRyM1uqzxMKp9nqmiI25LG4yU0cWiyS5/YHWW8Su+ldaNPCce34sqy1y+5S9a8AAtQ86D+CD2v2JQg+T8E7ZA8XDBs= X-Received: by 2002:a05:6e02:1ca7:b0:2d3:efd2:f34 with SMTP id x7-20020a056e021ca700b002d3efd20f34mr3441848ill.259.1655223216103; Tue, 14 Jun 2022 09:13:36 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 14 Jun 2022 18:13:24 +0200 Message-ID: To: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [RFC][Under discussion] Fetch properties in const expressions From: tovilo.ilija@gmail.com (Ilija Tovilo) Hi Robert, hi Guilliam > > So, how does this change our mental models when writing PHP? For > > example, I generally consider `const` to be a "compile-time" constant > > (ie, generated/created before any code is actually executed). So would > > this allow code to actually execute before any other code (ie, by > > putting code in a __get()) and thus cause issues due to database > > drivers and etc to not be loaded yet -- or cause them to be loaded > > prematurely? > > True but that's already the case since PHP 8.1 and > https://wiki.php.net/rfc/new_in_initializers > (https://github.com/php/php-src/pull/7153), e.g. > https://3v4l.org/MSWi0: > > ``` > class Foo { > public function __construct() { > echo "Side effect!\n"; > } > } > > const C = new Foo(); > ``` Exactly. In fact, the only way you could invoke arbitrary userland code through __get is in combination with `new`, where side-effects are already possible via constructor. Enums themselves don't allow __get and thus can't lead to side-effects in constant expressions. If there are no other concerns I'd like to open the voting phase by the end of the week. Ilija