Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117540 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 62598 invoked from network); 19 Apr 2022 06:25:46 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 19 Apr 2022 06:25:46 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E338A180511 for ; Tue, 19 Apr 2022 00:59:12 -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_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,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-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 ; Tue, 19 Apr 2022 00:59:09 -0700 (PDT) Received: by mail-pl1-f180.google.com with SMTP id b7so4964911plh.2 for ; Tue, 19 Apr 2022 00:59:09 -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 :cc; bh=k6GNMa+ZB/Qx0l7hyitHm0O1gdyp9bE0AeRfEjGD2Vk=; b=TEZdZoboVz63TYy/3L7bn5Z3xQaYJ8UKNpB28NDsdGUki8TyE7xoIXByPfFLi7++j8 JlSbQDZRls466By6TuAEBUBnRfqzu9YRGXMVSzHwu9Fzrhm4CiD1POwy47JlFAr8/9I6 N5icJhqrgFt+mV426hF/6y5pqIi/SxLQLxsxAJsFcPhZL+ndGGkW1bnFRCggkyUYF91P 6OOY2CTHt8XGyKfJPDzW7X1UwfxQdJXqANc9pAw4OF1+NVTru3wvYMHuNjqolcr01KAP TOOJasCdWz6JEh19Fcf5AMFae4lZJ6t4Icdva1MZzOfRgUsT+oCrqC9+PluGDBymprG9 NthA== 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=k6GNMa+ZB/Qx0l7hyitHm0O1gdyp9bE0AeRfEjGD2Vk=; b=4sHkeXoJUJqeb19vuAtJe6kCK/BqNqPNxvpll4tf9i6Fw7BX4KuxWcu7s0U7mDvNZp /Z7NlIStXtZpczVt7lb8L6jzrythdZVt0SrpHyONlfucD9E1nuDPRTEmnvz/BAUtCO0Z CKFe7kSK8Q0K67uV4rLPPBecCyeMb8C5WmawdiqkUZnL1qOhHfUNgIiHwD+15cn2DE2G 5vnYEfsn7RV4ld/cbkBklmdxLaIkr/k6Pq43S0b3mdtxCSoNOJQkyVJdky5lfiyRX38U H4Zclr84svUHh2IU5ejXCER+UiCir3pCVwA0wrFUto9x4tUamCgbE3XesZN9SnYnRnKO 9tSA== X-Gm-Message-State: AOAM530aPhpQDj4CBpcb5f/fUx8r9Lhw/4PXn3uMcidaE86HAnbEALgM XSzna/QZVqLsTz3Lnams+n/+djeXmM0hNGc04ng= X-Google-Smtp-Source: ABdhPJyqJFIgdBas4u2/blMPkx7J0Jnb+7WPW7rCUvEJomRZlw8EFA/rtfuRss9FVUux9kkpjplg/GiY6QcSJAzitE8= X-Received: by 2002:a17:90a:af8f:b0:1ca:7bce:ce3b with SMTP id w15-20020a17090aaf8f00b001ca7bcece3bmr22778493pjq.224.1650355148218; Tue, 19 Apr 2022 00:59:08 -0700 (PDT) MIME-Version: 1.0 References: <4c685dfa-2a81-4eed-af70-3e34b7de50f0@www.fastmail.com> In-Reply-To: <4c685dfa-2a81-4eed-af70-3e34b7de50f0@www.fastmail.com> Date: Tue, 19 Apr 2022 09:58:57 +0200 Message-ID: To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="0000000000005ce49305dcfd4036" Subject: Re: [PHP-DEV] [RFC] [Discussion] Readonly Classes From: kocsismate90@gmail.com (=?UTF-8?B?TcOhdMOpIEtvY3Npcw==?=) --0000000000005ce49305dcfd4036 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Everyone, After quite a long pause, I'd like to revive the discussion of readonly classes and possibly put it to vote in the coming week(s). If I'm following, then this RFC is about 90% syntactic sugar for putting > `readonly` on all properties, plus disabling dynamic properties. That's > the long-and-short of it, yes? > Yes, exactly! > Does disabling dynamic properties offer any other advantages as have been > discussed otherwise recently? (E.g., performance.) > No, I'm not aware of any other advantages. The only reason why I included this feature into the current RFC is because otherwise a readonly class wouldn't be readonly. :) The same applies for forbidding the declaration of static properties. Is there a way to opt a given property back OUT of being readonly, or if > you have a readonly class and need to add a single mutable property to it > are you stuck adding `readonly` to all existing properties first? (I'm n= ot > sure I'm suggesting having such a mechanism, mostly just clarifying.) > Yes, you are right. This is an inconvenient situation for sure, but neither I can imagine any other way to back a property out of being readonly than to remove the readonly class modifier + add readonly property modifier where possible. Of course, the readonly property modifier doesn't apply to the internal state of objects... so doing the above is not necessary if you have to modify a readonly property which is an object. > It's interesting that this also provides a backdoor way to force all > properties to be typed, as a side effect. However... that also means you > cannot mark a class readonly if any of its properties are callables, sinc= e > callables cannot be typed. (I guess you could use mixed and then docblock > callable, which is a bit fugly but not a problem introduced by this RFC.) Yeah, you are right, an ugly hack is to use the mixed type for properties that cannot be typed otherwise (e.g. resource). I believe in case of callables, one could use the Closure type instead, especially since the first-class callable syntax has been introduced. I hope I managed to address your questions/concerns. M=C3=A1t=C3=A9 --0000000000005ce49305dcfd4036--