Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118424 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 2241 invoked from network); 11 Aug 2022 21:35:58 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 Aug 2022 21:35:58 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D12DE18037F for ; Thu, 11 Aug 2022 16:38:05 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS24940 78.46.0.0/15 X-Spam-Virus: No X-Envelope-From: Received: from mail.webkr.de (mail.webkr.de [78.47.173.34]) (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 ; Thu, 11 Aug 2022 16:38:05 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 6C3F31A15C2 for ; Fri, 12 Aug 2022 01:38:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=webkr.de; s=dkim; t=1660261082; h=from:subject:date:message-id:to:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=wfelfc3ldtxXB4W5IAOn/3TupFRo17z7ja8iaVyB8hQ=; b=lNsWZpwsHYHnv7kS2dV7iC9fqNy+EfmtCeIAJIlcekBTIhGlcR+iHb8mSblbjL7Qn5nKW+ JjoyeDhfXPNEfk2tCBzIPysZZZTRquhHnAuPiTOviP6yyPm7AFolp898u7STzUbnjBTjH8 ByiAvWRdJ3fGvZ8fw9aH90SL4cnMgeE= To: "'php internals'" References: In-Reply-To: Date: Fri, 12 Aug 2022 01:38:00 +0200 Message-ID: <0e6401d8addb$651ca9d0$2f55fd70$@webkr.de> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Content-Language: de Thread-Index: AQIYj4WUzxzLV9xtSCMZjUkct1AF5QGVaAZkrR3m0pA= X-Last-TLS-Session-Version: TLSv1 Subject: RE: [PHP-DEV] [RFC] Asymmetric visibility From: andre@webkr.de (=?UTF-8?Q?Andr=C3=A9_H=C3=A4nsel?=) Nicolas Grekas wrote: > But I'm also wondering about the use case where asymmetry would be > useful in practice now that we have readonly? > I voted against readonly at the time because it didn't address > cloning, and also because it deprives end-users vs code authors IMHO > (alike "final"). I would have very much prefered asymmetric > visibility back then. But now that we are here, what are the use cases? Isn't it (obviously?) to have setters that ensure all invariants of the properties are met? I'd still rather have Property Accessors as described in https://wiki.php.net/rfc/property_accessors, but I think AV is a step in the right direction. As for readonly, I don't understand why that exists at all. Yes, it's good that readonly properties can only be set from within the class, but only once, so you get setters that throw when called a second time, which I think is very, VERY unexpected behavior. Calling them "readonly" is also somewhat misleading because of course the objects assigned to those "readonly" properties can still be mutated, they can just not be reassigned.