Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108911 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 98638 invoked from network); 9 Mar 2020 18:10:32 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 9 Mar 2020 18:10:32 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 58083180563 for ; Mon, 9 Mar 2020 09:31:14 -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,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS36024 206.123.114.0/23 X-Spam-Virus: No X-Envelope-From: Received: from mail1.25mail.st (mail1.25mail.st [206.123.115.54]) (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 ; Mon, 9 Mar 2020 09:31:13 -0700 (PDT) Received: from [10.0.1.201] (unknown [49.48.217.223]) by mail1.25mail.st (Postfix) with ESMTPSA id 97A8E6052C; Mon, 9 Mar 2020 16:31:07 +0000 (UTC) Message-ID: <0EFD45F2-DCB6-43E4-B826-907AB4846A65@koalephant.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_AEF9F153-F728-42F5-86D5-ADE4130A6FDC" Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3608.60.0.2.5\)) Date: Mon, 9 Mar 2020 23:31:04 +0700 In-Reply-To: Cc: PHP Internals To: Benjamin Eberlei References: <7BAB0436-03EC-4183-BA5A-5A165DAE806E@koalephant.com> X-Mailer: Apple Mail (2.3608.60.0.2.5) Subject: Re: [PHP-DEV] [RFC] Attributes v2 From: php-lists@koalephant.com (Stephen Reay) --Apple-Mail=_AEF9F153-F728-42F5-86D5-ADE4130A6FDC Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On 9 Mar 2020, at 23:27, Benjamin Eberlei wrote: >=20 >=20 >=20 > On Mon, Mar 9, 2020 at 5:18 PM Stephen Reay > wrote: >=20 >=20 > > On 9 Mar 2020, at 21:42, Benjamin Eberlei > wrote: > >=20 > > Hi all, > >=20 > > I want to resurrect Dmitrys Attributes RFC that was rejected for 7.1 = in > > 2016 with a few changes, incorporating feedback from the mailing = list back > > then and from talking to previous no voters. > >=20 > > The RFC is at https://wiki.php.net/rfc/attributes_v2 = > >=20 > > A working patch is at https://github.com/beberlei/php-src/pull/2 = though > > work around the details is still necessary. > >=20 > > The RFC contains a section with common criticism and objections to > > attributes, and I hope to have collected and responded to a good = amount > > already from previous discussions. > >=20 > > There is also a fair amount of implementation detail still up for = debate, > > which is noted in "Open Issues". I have pre-committed to one = approach, but > > listed alternatives there. On these issues I am looking for your = feedback. > >=20 > > greetings > > Benjamin >=20 > Hi Benjamin, >=20 > I can=E2=80=99t comment on the feasibility of this RFC or the patch, = but I like the approach it takes to this =E2=80=98problem=E2=80=99. I = can already imagine a number of =E2=80=98nicer=E2=80=99 ways to achieve = similar/same results using this, so thanks for taking up the baton! >=20 > My one small query/request is about the `Reflection*::getAttributes` = method. Is there a philosophical and/or technological reason for why it = can only =E2=80=98filter=E2=80=99 the attributes by a single given name, = rather than being variadic and filtering against multiple names (i.e. = returning those that match any of the given names)? I would imagine many = uses (particularly within libraries) would end up wanting to retrieve = multiple attribute types they=E2=80=99re aware of all at once, no? >=20 > The name filtering works when using a common base class or interface, = so if a library has a class "My\BaseAttribute" and all related = attributes extend from it, then in the code you can do: >=20 > $attributes =3D = $reflectionClass->getAttributes(\My\BaseAttribute::class); >=20 > This would return all attributes matching. >=20 >=20 > Cheers >=20 >=20 > Stephen=20 Ah! I had wondered if that type of filtering would be possible (another = benefit of using classes for the attributes) but I didn=E2=80=99t see it = mentioned, and wondered if the intention was to leave it to userland.=20 Cheers Stephen= --Apple-Mail=_AEF9F153-F728-42F5-86D5-ADE4130A6FDC--