Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108862 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 44524 invoked from network); 5 Mar 2020 12:37:46 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 5 Mar 2020 12:37:46 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 86DF5180210 for ; Thu, 5 Mar 2020 02:57:25 -0800 (PST) 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.4 required=5.0 tests=BAYES_05,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_H2, SPF_HELO_NONE,SPF_PASS 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-vs1-f52.google.com (mail-vs1-f52.google.com [209.85.217.52]) (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 ; Thu, 5 Mar 2020 02:57:25 -0800 (PST) Received: by mail-vs1-f52.google.com with SMTP id y204so3266463vsy.1 for ; Thu, 05 Mar 2020 02:57:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=127R83QjLChqPMNkDETO+nIePp2bhvvniUsNf+OOV4w=; b=O3IECKD//E1Gz7uD2uuyAzUK//cmSWRS/bHxnJOWhq6uROdDMpHfuwAEGQWcPjOVSx 2LMUpQrxk1/+3L97NBYwX8pwNqgWmB073IZEwYZ/Z5x63lI7gnKTnl7mI6jloqkrgP9L gcrhXS5JyIWXSv0h4vNC09nHabj+aMUW+XaYu4k4d9UgqQ+hdoXuQrRwjippc09ZbMMi uiD4Rce2U/zwP9mullZFfevGzxbWc1OGSWMXd2iVjeqnt/Uhw1hHE6IrGDBfpHt4LVcp 7VN1bMdHO0LTDYNi+f3fJTc/zuWiLqn5dCncFEoD/WoAIFz/TV3NwNRV+QfSMhLzsLoM Fi+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=127R83QjLChqPMNkDETO+nIePp2bhvvniUsNf+OOV4w=; b=Ii6WaidWHgwJ4SpnFgmKW1Nw99y0xU396LH/1G0tfRARzGvmisg1R7JPio7/qMvz4B ATcOzQe/2gWg7ge3VlFpENLSUhOuMhDAE8gvwLrEPqAXbvmw/2+MgXTzdh28+4j6e+3o 71IiwQiwKW9im1Qw33JUOj7RCHZSv96UT9oBmSAmxNDqHUTziSGeSSjkNaPXR12Cr65n IW410ChoDcwXHx36/Jpo30UL6ZcuCqpMj4KXElRvklEWYs8VsQ4K8if+Hpitt8AZr2S2 FTfdS6PzTlNen65FqqS162Llpmu+PAImP9ouzurNbbpX/3fnqo7mvVAkzy0NuCcE2XpA hDdA== X-Gm-Message-State: ANhLgQ0q5L0BXhesrd2YRhHSrozPGMoEQuGx/hNE8JQcRZt958EuAn48 8BOYBQu1O3u991hy0zeKtcTg0RzIRZzumeUZaog= X-Google-Smtp-Source: ADFU+vsKuzZ/rGJ21DeFPHE2owKDlLkcle9bGsx+h52CPzsR9pSNsmWV9JhiXqsj445oAxcLub4KbAtm2xIjaA0kKOQ= X-Received: by 2002:a67:eecb:: with SMTP id o11mr4747105vsp.227.1583405839876; Thu, 05 Mar 2020 02:57:19 -0800 (PST) MIME-Version: 1.0 References: <8545d15e-ddd5-42be-8405-09697a077234@www.fastmail.com> <4d9688fe-cc57-44af-903e-05f4cbb1bbcc@www.fastmail.com> <6bcbf0a5-92d8-4cfa-a00f-e0e967fc037e@www.fastmail.com> In-Reply-To: Date: Thu, 5 Mar 2020 11:57:08 +0100 Message-ID: To: Nicolas Grekas Cc: php internals Content-Type: multipart/alternative; boundary="0000000000009f08c405a0196651" Subject: Re: [PHP-DEV] [RFC] [DISCUSSION] Immutable/final/readonly properties From: kocsismate90@gmail.com (=?UTF-8?B?TcOhdMOpIEtvY3Npcw==?=) --0000000000009f08c405a0196651 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > > I totally agree with this: there must be a way to work around the keyword= - > either via reflection or another means. Via Reflection, it could be a new method `->setWritable(true)` (next to > `->setAccessible(true)`). > I'm OK to support working around the keyword via reflection. Since my implementation uses a property flag to determine if a property is writable, and the flag is flipped after writing, the ->setWritable(true) wouldn't work. But I can imagine adding a ->setUninitialized() method, or adding a third parameter to ->setValue() which would affect whether the property flag should be first reset or not. Adding a separate ->setValue() method for this purpose is also possible, but I couldn't find a good name for that yet. What do you think? > Another way, which is my current preference, would be to have visibility = be > taken into consideration when using the keyword: > To be honest, I don't agree with this idea. It is rather a simpler property accessor variant with which one can define separate - but predefined - visibility rules for reading and writing. Furthermore, I think it's worth to protect people from their own mistakes. I know for sure that at least I'd need those safeguards. :) But if we are talking about unintended changes coming from outside scopes, and if we only consider "legal" use-cases, private and protected properties are already pretty much safe. However, if we also consider possible changes coming from an inside scope, and other, "illegal" use-cases, we currently don't have any protection. And not even property accessors or your idea could help here. Given, immutability became mainstream via PSR-7 at least, I think it would be beneficial to add first-class support for this principle. I remember that one of the criticisms against the implementation of PSR-7 was that immutability is not even possible to achieve in PHP (apart from the fact that PSR-7 uses a mutable resource for storing the body). Now, we could solve the first problem, but that requires us to stay with the proposed implementation of the RFC. Regards, M=C3=A1t=C3=A9 --0000000000009f08c405a0196651--