Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114738 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 86012 invoked from network); 5 Jun 2021 14:14:43 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 5 Jun 2021 14:14:43 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3B6101804D8 for ; Sat, 5 Jun 2021 07:28:42 -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-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (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:28:41 -0700 (PDT) Received: by mail-wr1-f53.google.com with SMTP id z8so12131716wrp.12 for ; Sat, 05 Jun 2021 07:28:41 -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=FoiYiUWUloMiHbDUemaBFZVx2W7oLE0YB6Sw1qQFQZc=; b=ZFYHGr67oqcsYTdYXsMLrwlWZXvg+2BmF9qyBbjpAOE4G8Xgr7uiiNAJF159GUM5Qy bkCE6oJutuejSpMNwADBjZxr+GcVjxpZe7yb5qzd/gYGLEHSjVToWKpYE9goD4UOC2fl SMQjuBG97WEzFTc12oij2EFdQxMYKnu+ElwnuvpcuIYZv5o08TQn1MtaprpKjG5J8Khs efuEeA4mizqfrwfs/wiKxpsswR6+KkV3MEWZvyHrxg5h0rSwyqquiyQL1OUOf/nkrYHs eQxxhp1M1i0OWQzXXx0ek9zlVzhu08+b/VCe3cNBqhMza2CRxTdrjqQmiEfkAEubonmi qokQ== 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=FoiYiUWUloMiHbDUemaBFZVx2W7oLE0YB6Sw1qQFQZc=; b=XPYgW3dwCcCQgv5gibVChji9gXqekG4TJJRH5KJx8TjpyrNUDqC6Lc+BmMh+fnRvsO qhq6PnIzUPTRMzmP0qZ3YlJgqsv1Vp/fKZKvpYXE1mssu7LEUx0If4TpvDF12EnuOVMR r0ld5Cry8gd85/mJ3rVCiZkqxl+j2yEHp+IvdJEunOnW4Ee+H9SzNVRG4iladeVXaNB5 xctGTyEYfNpiUhGW7OgK9MKBP70V23bXEtXe8zyCVsu0wdBllEK4NnF6YAuY3CRhXIYk dB0ak4tlbObP2Q2rEYX7+CYG6bOXmwQeFEldvdPkuMsprqUq1Cyz2b6VXDeGn5LHN52I PJxg== X-Gm-Message-State: AOAM532rlv1jLah7ihQFnIxwxYWs3yy5ddFQWP0IofkDrJZwF+ZWAe/W 2ZOKx7hFydLB6s4yiakdxXzhbq42r2OI2XlcVIezHg== X-Google-Smtp-Source: ABdhPJyJ8N75JFffsOp8KrrdZ2mtFuhJFR2OO0ILfgblznRY8m7F/fCcnX6/Z4a4owFeCYma4nw6Of6s7vK8hMv2AhQ= X-Received: by 2002:a5d:6405:: with SMTP id z5mr8670329wru.39.1622903318373; Sat, 05 Jun 2021 07:28:38 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sat, 5 Jun 2021 16:28:27 +0200 Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000cbf8e805c4059f5e" Subject: Re: [PHP-DEV] [RFC] Readonly properties From: kontakt@beberlei.de (Benjamin Eberlei) --000000000000cbf8e805c4059f5e 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 > --000000000000cbf8e805c4059f5e--