Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120864 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 77235 invoked from network); 25 Jul 2023 20:21:24 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Jul 2023 20:21:24 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D0CF81804D4 for ; Tue, 25 Jul 2023 13:21:23 -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, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS19151 66.111.4.0/24 X-Spam-Virus: No X-Envelope-From: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 25 Jul 2023 13:21:23 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id C9EC95C0036 for ; Tue, 25 Jul 2023 16:21:22 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute4.internal (MEProxy); Tue, 25 Jul 2023 16:21:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-type: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=1690316482; x= 1690402882; bh=MJ6QEo8cv0B57D3yT/86pyoUpkVWgmFXH7JWSqGwVP4=; b=J bxatZtH1LWk1KszMmjnOSjhO7pZcsxmoBOwbNyUJrixmA/x+xtTAEuGLQxzl1Ne3 oMi0bgMpxvlUYmL9QCRdM6YYQm8DwVlKzULtUl8QG7VHbwDZu3Kk+o0WPPsUEDC5 QhPOsn7TOmCG357NL70Fcl03r/Ea5Y7I1Vj7ZuGPU+LQKed1OMJ9q626tWDZWUrO s8aGsQJJC5hAo9RKvhCcUrWCoTDU5QpS5CwsAGbwXmfowonC8JJGFJYFhbsgLfDN vfZoZD9V7jV38FnGh5+63qs+Xtr6Ryv/bTLc9IBNG4BXyTmIe8JZQVT2Ax8YmNnT 0aV3Bb7tA2T/9cac+dDAw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type: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=1690316482; x=1690402882; bh=MJ6QEo8cv0B57 D3yT/86pyoUpkVWgmFXH7JWSqGwVP4=; b=3bDCw/XEJh9QwVbjPek8S7+5ts6vC xHfaScjnEW4Q+0YqJ6wDXOL6ycueiqDBD/JsOIO80+eky8g3/uM+yy+FFvyDO825 Hw3N0OEBoK593VJAUaEcZZoKzVKI9q/9OKwWxIpgh50U16HdD0J0dLVQOp1J0LQv +ZVv9/QcsB5kaykpT3kfvawMMaiaA3SQ5VbLNuxnK5kllPDYowxwF6FmB7Gqs2nI HRkbTdvr1CiaTde/GXQvHIO8mUrclppOvOfIWJ70rAvykGHisr3glkCazXC90zr9 ujKFPAIp0tbENglKmKOH/CKpolqGnPgdbAFzQ+TCI2LwsY8t6wHhPlXUA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedriedtgddugeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdfnrghr rhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hmqeenucggtffrrghtthgvrhhnpeekteelheffgeefvddufeeujeekhfdvtdeuuedvveet ieevheeludegjeduhffhteenucffohhmrghinhepghhithhhuhgsrdgtohhmnecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhiesghgr rhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 85A611700089; Tue, 25 Jul 2023 16:21:22 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-592-ga9d4a09b4b-fm-defalarms-20230725.001-ga9d4a09b Mime-Version: 1.0 Message-ID: <91d45d72-5cc1-4fa4-bf50-cdf645a2e2af@app.fastmail.com> In-Reply-To: <19f70187-09d5-4f60-ba01-265f2e97f7cc@app.fastmail.com> References: <19f70187-09d5-4f60-ba01-265f2e97f7cc@app.fastmail.com> Date: Tue, 25 Jul 2023 20:21:01 +0000 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] New reflection methods for working with attributes From: larry@garfieldtech.com ("Larry Garfield") On Tue, Jul 25, 2023, at 6:09 PM, Ollie Read wrote: > Hello all, > > A while back, I wrote a lengthy post about suggested improvements for > reflection, but I would like to come back to address additional methods > for dealing with attributes. (I have an open git issue here: > https://github.com/php/php-src/issues/8489) > > I'd like to introduce the following three methods on all reflect > classes that have attributes: > > hasAttribute(string $name, int $flags = 0): bool > > Uses the same filtering as getAttributes(), but returns true if a match > is found, false otherwise. > > getAttribute(string $name, int $flags = 0): ?ReflectionAttribute > > Also uses the same filtering as getAttributes(), except that it will > return an instance of ReflectionAttribute if one is found, null if none > are found, and will throw an exception of more than 1 is found. > > getNumberOfAttributes(?string $name = null, int $flags = 0): int > > Again, uses the same filtering as getAttributes(), and is to attributes > what getNumberOfParameters() is to parameters. I appreciate that this > methods use may not be obvious, but I wanted to include it for > consistency. > > I'm relatively confident that I have worked out the best method of > implementing these, and contributors have agreed to merge a PR, which I > will start shortly, should there be no objections. > > --- > Best Regards, > *Ollie Read* I'm not opposed to these, but would this be a good time to also add an interface for attributable reflection objects, so that we can type against that? These methods would all then go on that interface. --Larry Garfield