Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118377 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 36114 invoked from network); 8 Aug 2022 00:52:54 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 8 Aug 2022 00:52:54 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7DBFC1804F8 for ; Sun, 7 Aug 2022 19:54: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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171]) (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 ; Sun, 7 Aug 2022 19:54:05 -0700 (PDT) Received: by mail-qt1-f171.google.com with SMTP id a4so913262qto.10 for ; Sun, 07 Aug 2022 19:54:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20210112.gappssmtp.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc; bh=SVtLG4I+jSsqQB6Vg6B8Vjqq0QOfBLk+QEkhO/eeRls=; b=2nN+m4GXRrqocdsga8z+A8/mAj2E4wFPRlIEXplNPpaDY5ps21oZAokdiZpz3czrvZ P6sPEB+NFSggc1BIJ6P8HXSkyWEO/cnl3RnqiJgMpnd95wiL6+jhvzsPDANOEFQmOA9v 5wrpomNwIAmkj+DCV/80276y2Mbdb1ucrxG+iLZrv+qNiH3VYIKkG6NQZovz/j2pBX+A XwGJcTUH6DZu8+dwWC/yaVRNeRY2I4LmfF6gOXaam2Yyl52r/LSxM28eD9mqKKHuJt2G 82Wy9RGZ1OSl+MaT2tThBIFlT4fh3YahyeMg9xkmYrcr0QnlBhLEE8nwI1Ik7nCfLBCw 1Zfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc; bh=SVtLG4I+jSsqQB6Vg6B8Vjqq0QOfBLk+QEkhO/eeRls=; b=LTvun+XzkkAReVizAeRfQKz50mSrl6P+ZO5b/5qKTiDPh4j9yPjx/cQj5H/bhhOPZ0 k0BZPVZr9uxaHrmglm9mYO73gvWo3pG5AjoregWX0TPj2vmLQcmSz+ognObH+sfA736w 5Cl0Sr9uR/d+A1eNJFtuRkTTzn5XlMmO1KDm5hgPFKo0DJIdP1UhMcfgYOmB+vGQNqhL 2GuYslNmrzNery/fsEMw3/U95kmgcyERDoS/YGnk8CNmayghYPgnApSIm4ekZLK75vzg XchrbkiM4qO+F/KoerTuOmUJ6ZvioOstf+Yasmh2Y0jdPQOdgkKhphDedm3Q+mk7rFHO qkYQ== X-Gm-Message-State: ACgBeo2NiyN6s5KZQhaFIySxWHUOT46CXNvYarIyugOYB9dyQtpimNnw ffCSCkvlrNVqntXBqbJpnONftA== X-Google-Smtp-Source: AA6agR5QsKIDBS5yR4O7iJzxiXBNdQfcdihkCChFOF9T1f79S45PmRbj4VHCigZzaVKQoZqlvyPewQ== X-Received: by 2002:a05:622a:448:b0:31e:f718:6833 with SMTP id o8-20020a05622a044800b0031ef7186833mr14771935qtx.154.1659927244103; Sun, 07 Aug 2022 19:54:04 -0700 (PDT) Received: from [192.168.1.10] (c-24-98-254-8.hsd1.ga.comcast.net. [24.98.254.8]) by smtp.gmail.com with ESMTPSA id q16-20020a37f710000000b006b958ae8d11sm1045891qkj.37.2022.08.07.19.54.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 07 Aug 2022 19:54:03 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) In-Reply-To: Date: Sun, 7 Aug 2022 22:54:02 -0400 Cc: php internals Content-Transfer-Encoding: quoted-printable Message-ID: <6576371A-9C18-4BC4-ADA6-8F364208BF01@newclarity.net> References: To: Larry Garfield X-Mailer: Apple Mail (2.3608.120.23.2.7) Subject: Re: [PHP-DEV] [RFC] Asymmetric visibility From: mike@newclarity.net (Mike Schinkel) > On Aug 5, 2022, at 1:08 PM, Larry Garfield = wrote: >=20 > Ilija Tovilo and I are happy to present the first new RFC for PHP 8.3: = Asymmetric Visibility. >=20 > https://wiki.php.net/rfc/asymmetric-visibility Conceptually, I believe this would add useful capabilities to PHP that = are impossible to implement without: a.) Likely-sizable performance penalties, and=20 b.) Unfortunate edge-cases; e.g. property_exists(), get_object_vars(), = etc. Still, here are my concerns with the RFC as it currently exists: 1.) The syntax of "()" feels inconsistent with the = rest of the language.=20 PHP has function(args...) and (), both of which can be viewed as = "a function of 'args'." However, "private(set)" is basically a = constraint, not a "function of 'set'." PHP also has function(args...): which is a constraint so I propose = we consider the following syntax instead: : Thus all of these: public:get public:set private:get private:set protected:get protected:set 2.)The idiom "public private:set" is hard to reason about when reading, = at least for me.=20 It also feels inconsistent in that it requires one type of visibility to = be constrained, but not the other.=20 Speaking of "explicit" from one of Larry's latest replies, I propose we = consider requiring asymmetric visibility *explicitly* declared, in all = cases. Requiring explicit declaration would:=20 a.) Make asymmetric visibility easier to reason about, and=20 b.) Ensure consistency when asymmetric visibility is used. Specifically I would propose we make these INVALID: public protected:set $; public private:set $; protected private:set $; But all of these following VALID: These as-is for backward compatibility and an obvious default behavior: public [] $; protected [] $; private [] $; And these where behavior is explicit: public:get protected:set $; public:get private:set $; protected:get private:set $; As well as these: public:set protected:get $; public:set private:get $; protected:set private:get $; And of course these: public:get public:set $; private:get private:set $; protected:get protected:set $; 3.) I have concerns about the proposed methods isProtectedSet() and = isPrivateSet(). =20 These names feels like we are asking if some thing "Set" is "Protected" = or "Private" where no such "thing" exists in this context. =20 In other words it reads as if you are asking "Is it a *protected* Set?" = or "Is it a *private* Set?" Such naming also does not relate to the = Property itself which is what the prefix verb "is" is acting on. I would propose instead we consider the following are these instead = would be asking the *ability* to "Set" the Property is "Protected" or = "Private" where The Property is again what the prefix verb "is" is = acting on: isSetProtected() isSetPrivate() isGetProtected(), and isGetPrivate() #jmtcw -Mike