Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120863 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 70683 invoked from network); 25 Jul 2023 18:09:52 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Jul 2023 18:09:52 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A62341804BC for ; Tue, 25 Jul 2023 11:09:51 -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,HTML_MESSAGE,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, 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 wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) (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 11:09:51 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 76D583200962 for ; Tue, 25 Jul 2023 14:09:49 -0400 (EDT) Received: from imap44 ([10.202.2.94]) by compute1.internal (MEProxy); Tue, 25 Jul 2023 14:09:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ollie.codes; h= cc:content-type:content-type:date:date:from:from:in-reply-to :message-id:mime-version:reply-to:sender:subject:subject:to:to; s=fm3; t=1690308588; x=1690394988; bh=TjJ+Ax7s6BJwx/bJmy9C6vC5K COt/42pk761diBb2ME=; b=drmX7Dwh9wI3HqgA1TK3tI8bnMDg8IPqAxeexc77E XpjByODsi3lVg/69xhARSZd/DCOQFP9fh/smuKe3is3ASHKqna4U9p49H627M5yJ hcRbtX7hMjQ06n2yExG7tXCgrM8TMfdnm4SOqxHuySicHiauCwIqnSASs0WcoPJd 52lWmnoWKwZhH/rGxQwTBdi16jjCX6zxVs0jqKtkdBE0PMvSpCDRpgOeB+NUw7MY E3SIU24qDx7rk+9VcSyQ8roJ+qWOAbewaUAs6BY0RXnQxh4kqhv4MFiUXw8YUMbe 5eZ/fErbzeYwM5+l9z8l6aUGwxsdZFrESctOVMevBfrLA== 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:message-id :mime-version: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= 1690308588; x=1690394988; bh=TjJ+Ax7s6BJwx/bJmy9C6vC5KCOt/42pk76 1diBb2ME=; b=kgK63NV+y89vM3ES15bV+agIBbJ49JmuoCml9j3YdgykbjY8kvQ WzUz36ihZ/otS6tmm4//0Sg5a2aV4kgZLx1npk1Gd9225hppvLUhwGgajddgGR1X eIYoAWmRm0QEqRBRw4SjS9ryLC1Yv0yd/y18VylJyXKE5WKCNt0KQ28vNXkk5e7i 8uaZWAoq5x8Zi7eVQXl1H3CYS3bngjHjDLxUISyXhWwwGjrBwsx01Cub0KOqKGEd JwxorM9XKUn0G66DNRHUVp3t1/+HCZs7YyReFfCKazsbQE2LkZWuB2/8XgXtuTFt NgwFiZlMbIODv0+8Q0W8jcOn5m0QeQD+JNg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedriedtgdduvddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfffhffvufgtsegrtderre erredtnecuhfhrohhmpedfqfhllhhivgcutfgvrggufdcuoehphhhpseholhhlihgvrdgt ohguvghsqeenucggtffrrghtthgvrhhnpeeghfetkeegheeijedtleeliedvffdutdetue etueffhfefjeevveffuefhudfgleenucffohhmrghinhepghhithhhuhgsrdgtohhmnecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepphhhphesoh hllhhivgdrtghouggvsh X-ME-Proxy: Feedback-ID: i835c46d5:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 4818D36A0075; Tue, 25 Jul 2023 14:09:48 -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: <19f70187-09d5-4f60-ba01-265f2e97f7cc@app.fastmail.com> Date: Tue, 25 Jul 2023 19:09:17 +0100 To: =?UTF-8?Q?Bj=C3=B6rn_Larsson?= Content-Type: multipart/alternative; boundary=9be6434eb2e346498cae92052a284b82 Subject: New reflection methods for working with attributes From: php@ollie.codes ("Ollie Read") --9be6434eb2e346498cae92052a284b82 Content-Type: text/plain 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* --9be6434eb2e346498cae92052a284b82--