Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120797 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 13551 invoked from network); 12 Jul 2023 18:04:31 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 12 Jul 2023 18:04:31 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0DC36180511 for ; Wed, 12 Jul 2023 11:04:30 -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,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 ; Wed, 12 Jul 2023 11:04:29 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 4174F5C00E9 for ; Wed, 12 Jul 2023 14:04:28 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute4.internal (MEProxy); Wed, 12 Jul 2023 14:04:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding: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=fm2; t=1689185068; x=1689271468; bh=CW9k0LBPLi xYuiJYbESye9znduocK9/nlnEDXITCh/k=; b=QUXnnQpFlH84P2ZrNILoXN1zoL JOf5fIaWUl3avSde46w6dwKeO5P6AFGQjhU6wBt6O3o1gmU3CUMaDZtocMZtA8On BKAApocQeGDI8H4BvHlgXE0h2G/DFsYWFZsFDxsMLM+e5SVYDpen95R69sI9vZBT 3fPXf/ezdeHvopjYXhGI8GcAuwNX5wUvxPb6MWELUdDKyB0QHOr7kMpKVoqAQuRV hfSFL1jC6gKOjIAGCQAmU43ge3bPsf4PaWxyY3DUMts8uN5PMvKuVrr6JdNMB64u Pl6JJYAyc09JbxoM5AwPdvqE1CtkXHReKO6x/Ot64s88B+nA1+JFBXa1t9EA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding: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=fm2; t=1689185068; x= 1689271468; bh=CW9k0LBPLixYuiJYbESye9znduocK9/nlnEDXITCh/k=; b=O pkJuHil56LWpwPfpYImLP5CS2BHf5/ENvSyICHVvxgRm4WQeSjCtiQDVZcW+7uhI m4qmsxB4DdvcnPrfl2mniQzmtY7e0O9SelN/CrUMglYzJ2HwpMqiCsuzDwW2RpUK 2LvvedrL4POWELvg6yRrZYadbboIzHe0yPDqwxplGZpkUhZKnpfdyU7KaneuoFnh 8lNsqlB8QAV3YKr7k4vR00p1tl1YdsJLqrGWV43bsiW2i5cZPe0dzwWQqeMnDwhm jJFQfi+lkImACJDToqh4VBxAWqOL1JGm8sOYc3wEk+v2+uY2ceg64lX2qXgcib56 MyOoxTnprs087MrEXrRaw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrfedvgdduvdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgfgsehtqhertderreejnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepffffffejffdugfegvedviedttedvgfejffefffej leefjeetveehgefhhfdvgfelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 5C6D61700097; Wed, 12 Jul 2023 14:04:27 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-531-gfdfa13a06d-fm-20230703.001-gfdfa13a0 Mime-Version: 1.0 Message-ID: <3d9f4cac-7840-42c9-be9c-e9fc3bcc030a@app.fastmail.com> In-Reply-To: <906b41e4-dcbd-4a03-9d10-33723ce1c708@Spark> References: <29da91e9-d649-49c5-a415-46a84d22d531@Spark> <906b41e4-dcbd-4a03-9d10-33723ce1c708@Spark> Date: Wed, 12 Jul 2023 18:04:07 +0000 To: "php internals" Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Reflection*::hasAttribute() From: larry@garfieldtech.com ("Larry Garfield") On Wed, Jul 12, 2023, at 3:25 AM, Robin Chalas wrote: > Hi internals, > > It is common attributes to be used as markers. Just like a marker=20 > interface with no methods, such attributes don=E2=80=99t have any para= meter. > > Examples from Symfony: > - #[Ignore] indicating that a property should be skipped in a=20 > serialization contextl > - #[Exclude] telling the dependency injection container that a given=20 > class should be skipped from automatic service registration > > > From Doctrine ORM: > - #[Id] to tell which property of en entity class should be mapped as=20 > primary key > > Those are meant to opt in/out some behavior through detection only. Bu= t=20 > with the current API, such code needs to call `getAttributes()` while=20 > it doesn't care about the returned ReflectionAttribute instances. > Hence I=E2=80=99m wondering if we could add a `hasAttribute()` method = to the=20 > reflectors that are targetable by attributes. > > Does that make sense? > If it does, do I need to open an RFC for that feature or is a pull=20 > request be enough? > > Anyway, I=E2=80=99d be happy to work on the implementation as a first=20 > contribution to PHP. > Looking forward to your feedback. > > Thanks. > Robin I think that would require an RFC. To clarify, you're proposing to replace this: count((new ReflectionClass(Beep::class))->getAttributes(Ignore::class)) = =3D=3D true with (new ReflectionClass(Beep::class))->hasAttribute(Ignore::class) Right? That doesn't seem like a huge improvement. --Larry Garfield