Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109634 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 27615 invoked from network); 14 Apr 2020 16:54:02 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 14 Apr 2020 16:54:02 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 760241804CE for ; Tue, 14 Apr 2020 08:23:44 -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.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS11403 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 14 Apr 2020 08:23:43 -0700 (PDT) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 07E7D4C6 for ; Tue, 14 Apr 2020 11:23:41 -0400 (EDT) Received: from imap26 ([10.202.2.76]) by compute7.internal (MEProxy); Tue, 14 Apr 2020 11:23:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=JOPCxkM7NPGD4FI6s5M3zS8ixFjYIJO6do2fK2HXL SQ=; b=Jp3DTHt4HUw5Uj7z5+4whjZrQa0rVGRPywzJDWnIoG42jFoDxjB0dXVyY YYN8By82QkrPpOAgruqoJ1SF3kB/O3npVSgEyjbv5wx3LQoOsbaqwnfJb8CLc0bt vQiATKDl6qYh3RmGTMJBvBQyfO2lauNn0BAffjJKepITJwoSR1w2RMPVhw4tY+xH 1fZC061gzMOHMR8Jwlxv8c3uN1xqHE6nD4B+/+a5VQi0WHM7C2ArD2MoP9f3KXrz HFsn+uRpV8etRHgZwLdhe/ZLLeDMV5A15INPy00Ulfd7/HVQGB18EgujOijlRGyS Q/GOx10s3pJm5u0sywbOhpLLtYWqg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrfedugdekkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtgfesthhqredtreerjeenucfhrhhomhepfdfnrghr rhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hmqeenucffohhmrghinhepphhhphdrnhgvthenucevlhhushhtvghrufhiiigvpedtnecu rfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homh X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 3BA2C14200A2; Tue, 14 Apr 2020 11:23:41 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.1.7-1130-gd0f8b30-fmstable-20200414v1 Mime-Version: 1.0 Message-ID: <16620f3a-1eb6-437e-aa6f-05e5be2aa713@www.fastmail.com> In-Reply-To: References: Date: Tue, 14 Apr 2020 10:23:19 -0500 To: "php internals" Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Re: [RFC] Attributes v2 From: larry@garfieldtech.com ("Larry Garfield") On Tue, Apr 14, 2020, at 6:00 AM, Benjamin Eberlei wrote: > Hi everyone, >=20 > I have updated the RFC with much of the feedback received here, on Twi= tter > and Reddit. >=20 > https://wiki.php.net/rfc/attributes_v2 >=20 > The following changes were made: >=20 > - Changed to support the same attribute multiple times on the same > declaration > - Added support for attributes on method and function parameters > - Replaced *PhpAttribute* interface with an attribute instead > - Distinction between userland and compiler attributes and descript= ion > when each of them gets evaluated/validated > - Reduce number of examples to shorten RFC a bit and expand the oth= er > examples instead > - Introduced validation of compiler attributes at compile time usin= g a C > callback > - Offer alternative syntax =E2=80=9C@:=E2=80=9D using new token T_A= TTRIBUTE which will > be included with a secondary vote >=20 > You may have seen me mentioning that I don't want to deviate from the = <<>> > syntax, a topic of heated debate. As Martin helped me tremendously wit= h the > RFC and patches he earned to propose an alternative (including patch w= ith > prototype). So we will have a secondary vote on syntax being either > <> or @:Attribute. >=20 > Let us know what you think about the changes. >=20 > greetings > Benjamin This looks lovely and I look forward to being able to use it! Questions: 1. Why is exact-match the default for getAttributes(), and "instanceof" = an extra flag? I would expect it to the other way around. The whole po= int of LSP is that any subclass is a viable replacement for its parent; = if not, You're Doing It Wrong(tm). It also means that requesting by int= erface mandates adding the second parameter or else it will always retur= n nothing. What is the reason for not making instanceof the default mat= ch and offering an EXACT opt-in mode? 2. Regarding sub-annotations, can you still do classes as parameters eve= n if not as an annotation marker? Eg: <> function foo() Or is that also a no-go? 3. I see the most common case for attributes being getting the object ve= rsion. With the reflection API as currently described, I see two shortc= omings. A) I can't tell if an attribute has a valid object or not before trying = to access it, which would presumably fail spectacularly. I believe we n= eed a way to know if getObject() is going to return a valid value before= trying to call it. I think this is a hard-requirement. B) Related, as is getting all attributes as objects looks to be rather c= lunky. =20 $attribute_objectgs =3D array_filter(array_map(function(ReflectionAttrib= ute $r) { if ($r->getObject()) { // Needs something better here. return $r->getObject(); } }, $obj->getAttributes())); That's gross. :-) Can "get all the attributes that can be formed into o= bjects" be its own operation? $obj->getAttributeObjects() or some such,= that skips over non-instantiable attributes and instantiates the rest? This isn't a requirement, but without it I predict virtually everyone us= ing attributes is going to have to recreate the knot of code above. Thanks again! --Larry Garfield