Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118360 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 52758 invoked from network); 5 Aug 2022 18:24:50 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 5 Aug 2022 18:24:50 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 94B561804D0 for ; Fri, 5 Aug 2022 13:25:27 -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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS29838 64.147.123.0/24 X-Spam-Virus: No X-Envelope-From: Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 5 Aug 2022 13:25:27 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id CBB07320082A for ; Fri, 5 Aug 2022 16:25:25 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute1.internal (MEProxy); Fri, 05 Aug 2022 16:25:25 -0400 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=fm3; t=1659731125; x= 1659817525; bh=a4YI7H0I2k3z16Q1obHYdtUcdGGga76EmxCsFfReQYc=; b=L 4Iwsm5QxHAN1zhYttlzW0DEUBeA11wTAC/vMNit5mIORFi+1UYJI9aCC5sAt4FJ0 51BtdNvMVfL7YD+Vt+B01IAGmNPrYZhPre4qgA0LbsnKeWUoO3e1f0VQNGWcMFyh /x81tRifQekye9kEbOmFwHYCXW60274jc4CF+7+6t7n7mOhCHGn5bhQh/0YQRdv2 JWyvZHBo2Noa/CCEX5VcR6cV6gGHOoFFqXpS7DC4Uv+6HgD8SNIJ7rlNPde0W190 2axQ6aZpv14KcrKZOu2MFC9NhIWpD9vTexY1rWnowEsXGiQVnQKD2Fqe4Eh/kC2k i9OwPoK5g2ILH2cd7XdDw== 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= fm3; t=1659731125; x=1659817525; bh=a4YI7H0I2k3z16Q1obHYdtUcdGGg a76EmxCsFfReQYc=; b=fOQMzLDCgF+7HZb8b4ipKUBNsD5RzkDqQJv419Wl/4/t 9MiQDlJyqssog9USyinzDJMewFUHpvOehCz7GN1s+48p/vMtGjKsqU1RBIsKYGL5 7dghSLwf+RlTALohQ5TcuzC5ragD8sjHzpC4jXqE3j7fNOw1lhwioYmtm6xz653B dyoWVhKkUh1nkjkOeEF2GFGYc3THBSaT0AhEAagnYC6DX2ii8YBSjYKXkOleQs5A 1wTTVt6GaUsMe0V7BrtnHwmFo7mMekIbCuH/smf9ACOpnyKVOtwiIOd+Ie2aTN96 twO3xXt85Tv0isjoMWcP77asTP5DQyGexCZn/MN70w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdefuddgudehudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepveehhedvveejledvvefgleevffdtjeekledvkeeg heffgfeivdejhffhledtudetnecuffhomhgrihhnpehphhhprdhnvghtnecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhiesghgrrhhf ihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 0A2291700083; Fri, 5 Aug 2022 16:25:24 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-758-ge0d20a54e1-fm-20220729.001-ge0d20a54 Mime-Version: 1.0 Message-ID: <0923bd88-8e62-4386-bf6b-4ef9456780b4@www.fastmail.com> In-Reply-To: References: Date: Fri, 05 Aug 2022 15:25:03 -0500 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] [RFC] Asymmetric visibility From: larry@garfieldtech.com ("Larry Garfield") On Fri, Aug 5, 2022, at 1:08 PM, Matthew Weier O'Phinney wrote: > On Fri, Aug 5, 2022, 12:09 PM Larry Garfield wrote: > >> Ilija Tovilo and I are happy to present the first new RFC for PHP 8.3: >> Asymmetric Visibility. >> >> https://wiki.php.net/rfc/asymmetric-visibility >> >> Details are in the RFC, but it's largely a copy of Swift's support for the >> same. >> > > I have two comments: > > - For reflection purposes, having two separate methods feels like it will > be cumbersome; you'd need to check both to determine if you'd need to make > the reflection property accessible before changing the value. An > isPublicSet() would alleviate that, or potentially a getSetFlags() method > against which you could apply a bit mask. You'd need to add a constant for > public set I both cases. Reflection is a mess, unfortunately. :-( There's already separate isPrivate(), isProtected(), and isPublic() methods on ReflectionProperty, so this is consistent. Also, there's getModifiers() which returns a bitmask; these new flags would be included there. All these methods all do is check what is syntactically present, both the current ones and proposed ones. There's definitely room in the Reflection API for a "couldItBeModifiedFromScope($scope)" type method (and similar) that aggregates together symmetric visibility, readonly, asymmetric visibility, etc. into nice booleans. However, that is notably more work than just adding more syntax flag methods. It would probably be better as its own RFC, though I'd support that. If there's consensus that it has to be done here that could be done, but we'd prefer not as it feels like scope creep. > - The number of items that appear to the left of a property is growing, > making understanding a declaration increasingly difficult, and your > discussion of future scope indicates that this is likely to get worse. I'm > wondering if this sort of behavior could be indicated via attributes > instead? Something like `#[PropertySetBehavior(PROPERTY_SET_PRIVATE)]`. > Attributes have the benefit of being separate from the property > declaration, arguably more readable (one per line), and composable. This > might play into some of the future scope items as well. The list indeed groweth, but there's a couple of reasons it wouldn't be appropriate here to use an attribute. * It would mean get-visibility is a keyword and set-visibility is an attribute. That's weird and inconsistent. * There's a strong sense from many on the list that attributes should not be used for language behavior. Ilija agrees with that position, and I don't care enough to fight it one way or the other. * An attribute would be ignored in older PHP versions. For most attributes that's OK, but in this case it would be a potential bug source. Specifically, it would mean `#[PrivateSet] \n public string $value` would be publicly settable on PHP 8.2, but not publicly settable in 8.3. That means the integrity of the object is compromised on older versions. A keyword would make that a syntax error, which in this case is preferable. > Overall, though, love the design simplicity! Yay! --Larry Garfield