Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114739 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 87375 invoked from network); 5 Jun 2021 14:15:22 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 5 Jun 2021 14:15:22 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A7AA2180502 for ; Sat, 5 Jun 2021 07:29:24 -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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (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 ; Sat, 5 Jun 2021 07:29:24 -0700 (PDT) Received: by mail-wr1-f50.google.com with SMTP id e11so1949751wrg.3 for ; Sat, 05 Jun 2021 07:29:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=beberlei-de.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5dI94wTpqEKEsgRTi2jMSRQPe5nSnjGGkML5+S/v0Os=; b=Dlet1C4/6LJ+6L1270Y4SfL7R8OWeMlZyDs6g4Mt/YMCMzT+8QfxYjdPlJrYX9sUnL 9XqlPijkplmVKHDskt1m52AM6r3EtrfHdOdwtjn47msMoyLLa0ZGfb87HgPmxBKYA6+4 ccgtDMprMzoPqSlbz2sXkijR+ZygdD00MehqquK9+M95GypsuQiu1cQ+WwkdmuniCZmn gstW8G9hXLRhsUeLS9/LkPo9M077r9sTTScd3EcYmnj+Or9F45Ys0C8HmoWT16KmpuQr W1HCpy0Gi47+ZnnDlthAFFnZ4CA2ruzE8uC7tbnv7zMXCiThALsP8X23qFqpnkor3ON0 KvxQ== 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=5dI94wTpqEKEsgRTi2jMSRQPe5nSnjGGkML5+S/v0Os=; b=Zlz2e8AktqXQnBtfPprtMNkqe2X5qMHYNZzHjGmLqGgwnJH3HerynusbyCAJuR0WCL snFofe+ZGCA/Vqs4Ca9kvbzLyZKqYKUhJ83DokYwEnmgKNvWt6lvCGQMmzxWOxEPkDP2 Sxf08owtn66yoZOwBOE0QVULlkhoBT5D3TKf1tcq9bc0XT0lnxODL9L6cCC07v9XDiCm 2pTkcEd9YMlkWFFxfDXfx8ovFfowWW1s1Y73IOkqdou9Ylf8Y8nETmyu1Z2VNk1I9Egm M5fV1TSli4xjHWp6jmxxtiU310AifSAIKZx0gFKQke3AjdrqzPGfDnlmm9V0U69ZpqrO hwoQ== X-Gm-Message-State: AOAM530zOAZR9Z8WY/Wc5dTPZgLuxfHPiwuY3n9x2TFUxKhwwJIldDXk hLvzKv5sMdxnKFdk+cKE9PAeGeyKyoLkK/FhZusukw== X-Google-Smtp-Source: ABdhPJzZcqacbOIClpEu4lgDxjF1+fT7mAU9JTuB/XPWTG+8R+v/ToFep2Oyg0H2gwcPz/njPvv7f04ifqJGddl4mbY= X-Received: by 2002:adf:d227:: with SMTP id k7mr8809448wrh.271.1622903363110; Sat, 05 Jun 2021 07:29:23 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sat, 5 Jun 2021 16:29:12 +0200 Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: multipart/alternative; boundary="00000000000076996a05c405a21f" Subject: Re: [PHP-DEV] [RFC] Readonly properties From: kontakt@beberlei.de (Benjamin Eberlei) --00000000000076996a05c405a21f Content-Type: text/plain; charset="UTF-8" On Fri, Jun 4, 2021 at 5:20 PM Nikita Popov wrote: > Hi internals, > > I'd like to open the discussion on readonly properties: > https://wiki.php.net/rfc/readonly_properties_v2 > > This proposal is similar to the > https://wiki.php.net/rfc/write_once_properties RFC that has been declined > previously. One significant difference is that the new RFC limits the scope > of initializing assignments. I think a key mistake of the previous RFC was > the confusing "write-once" framing, which is both technically correct and > quite irrelevant. > > Please see the rationale section ( > https://wiki.php.net/rfc/readonly_properties_v2#rationale) for how this > proposal relates to other RFCs and alternatives. > I have a question about Reflection support, the RFC states: > ReflectionProperty::setValue() can bypass the requirement that initialization occurs from the scope where the property has been declared. However, reflection cannot modify a readonly property that has already been initialized. Is there a reason why this is not possible? I am thinking about ORMs or Deserializers here where a pattern would be: class MyDataObject { public function __construct( public readonly $foo ) {} } $dataObject = $reflectionClass->newInstanceWithoutConstructor(); $dataObject->getProperty('foo')->setValue($row['value']); > > Regards, > Nikita > --00000000000076996a05c405a21f--