Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119005 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 48608 invoked from network); 14 Nov 2022 17:50:50 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 14 Nov 2022 17:50:50 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5D752180083 for ; Mon, 14 Nov 2022 09:50:49 -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=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS19151 66.111.4.0/24 X-Spam-Virus: No X-Envelope-From: Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (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 ; Mon, 14 Nov 2022 09:50:48 -0800 (PST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 6A9AC5C0191 for ; Mon, 14 Nov 2022 12:50:48 -0500 (EST) Received: from imap50 ([10.202.2.100]) by compute1.internal (MEProxy); Mon, 14 Nov 2022 12:50:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1668448248; x= 1668534648; bh=iSnD0hrEwE4U7FJnH91LFx2EBQlD4m7/NOV5qxKAVEw=; b=g SU3K/FgVf1Mcl9KuGnfpF9mkebDsOCAlBRyYLooNpmY4tYquZGV/nQX0jWnEb9A6 84RPNdl/K84Aug3gpsMjovoDJM1Rte5aB0rVXPwqEusG1+6QzdmPsKlccwyIiLnm D3b7wg5XXM5ZqyWVy9VFSDZB3/G1oeGb9XaZloxlu2qRcso0bSbRcdD78WX0Fwmx 2XLCHxs9aLxir5vV0U//XGO4ush8AluZGrAsGJRyhHfjdbepSgQam/U7JKint5js LPSKrRYLFtC6u/fFcD2LBCeK9HGW4gV5mLE0tX9xtBt7+TASjAmUu+3hRv+PD4xn u73bPligRlefw0IwVm4Fg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1668448248; x=1668534648; bh=iSnD0hrEwE4U7FJnH91LFx2EBQlD 4m7/NOV5qxKAVEw=; b=AihG7vGaPKURE8ATyFxH0YDMlEbbjefoKoPYmoqcOvvh MHTL+sy4Ov3qGAYG0UH6ZkLk3U6aC6gJdbiiUoc58Bfk18RaDoTG998OZ0yp6432 d4GWzxtQpYKyoSCoFjy8Ek2XJ8LHDutrWwLxdvvGPgsqP05y4FCbZ6ti1oxJ7dV8 ojsyiDEZsdm/pVvBMpO0BalpbENjgHWrs8l+DznjGG2UmyMv3y0P6pEtehq9am0Q NXuvK65gFZafXtwe8E6k+qdx+4TZWnbw0xyfqJrn8Of9zriWXqPnvJx47kawCCOY de/G9UszCoCYFGEV2znnxK30FEi747eNRE+wINkKMQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrgedvgdejkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgrrhhr hicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh eqnecuggftrfgrthhtvghrnhepgeelgfekudeivddvteffueejffdthfejieevhefgffek udevkedtvdelvddvffefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 3C9431700096; Mon, 14 Nov 2022 12:50:48 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-1115-g8b801eadce-fm-20221102.001-g8b801ead Mime-Version: 1.0 Message-ID: <030202ce-9df6-425d-baa0-c5c2ac8b4760@app.fastmail.com> In-Reply-To: References: <0854b030-c51c-4c1b-a7dd-22835a1e5da9@app.fastmail.com> Date: Mon, 14 Nov 2022 11:50:27 -0600 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] [RFC] Asymmetric Visibility, with readonly From: larry@garfieldtech.com ("Larry Garfield") On Sun, Nov 13, 2022, at 4:08 PM, Deleu wrote: >> >> >> This is untrue. You can declare a private property identically in a >> parent and child class, even readonly. I'm doing this now in a project. >> It works, but would be unnecessary if the parent's property were >> protected(set). >> >> --Larry Garfield >> > > I do understand the slight complexity here (perhaps stronger in terms of > implementation), but my assumption was that if a property is private and > "the set visibility must be tighter", PHP would never assume `private > protected(set) readonly`. In other words, if `private readonly` then > `private private(set) readonly`, therefore nothing changes. You can keep > the use of disjointed variables in inheritance provided they're all > private. The only concern is when a property is declared protected, which > then evaluates to what I mentioned on the previous email. I don't follow. Right now, this is legal: class P { protected readonly string $foo; public useFoo() { if ($this->foo == 'beep') { ... } } } class C extends P { protected readonly string $foo; public function __construct(string $foo) { $this->foo = $foo; } } The redeclaration of $foo is necessary because of the implicit private-set on readonly today. I have code that does this. If we go with options 1 or 4, then that could be simplified to: class P { protected protected(set) readonly string $foo; public useFoo() { if ($this->foo == 'beep') { ... } } } class C extends P { public function __construct(string $foo) { $this->foo = $foo; } } This would not require "set is wider", just "set is the same". If we changed readonly to be an implicit protected(set) instead of private(set), that would also resolve that use case but I do not know if that would cause other problems with code like the above. > I'm also under the stated assumption that `public public(set) readonly` is > not something needed to be supported. I am not aware of any use cases for it, though if it technically becomes possible as a side effect of other changes I don't object. --Larry Garfield