Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128236 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 2DD3D1A00BC for ; Sat, 26 Jul 2025 11:29:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1753529274; bh=xrEIyf+Lf1YQORJwNI5u8Pkfypa0eB5dbFgZhq/ilec=; h=From:To:References:In-Reply-To:Subject:Date:From; b=cVRL9+IUkwfcaVS9/CTDeoUn7xUJNEXbOE8oHw58rlhiKWKKlZxwPU8+a0z8gI3Vs egU7n2UdXg6sr4LhI8JruIrH45Yo0eXEutLx55owfZs5uq/F/RzWf+K98dJnB3GEnZ PcVlxlRhJbfhPyM2JvtOQ0SYqAfnBmt0SWaTaWpJDzCmoiZOtXofreTA28UJWEeFoy 4xzWD7LBFjtPgOVByRcPfdPVcdfIyG7fU87bCq2/ngmKEveUYeFr7yfIb60BA+BuYH a8U/CHfP7wdDjoa5FN66YJ18v3QjhRRR4d9wtCGrns0uqsA1aqssqHHW3MxT8jY5Er 1C079MBUbowFA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id CF65618005C for ; Sat, 26 Jul 2025 11:27:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.5 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_50, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_PDS_PRO_TLD autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from iguana.tulip.relay.mailchannels.net (iguana.tulip.relay.mailchannels.net [23.83.218.253]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 26 Jul 2025 11:27:52 +0000 (UTC) X-Sender-Id: yszpovajlk|x-authuser|juris@glaive.pro Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id B27B78A32F6; Sat, 26 Jul 2025 11:29:34 +0000 (UTC) Received: from server52.areait.lv (100-126-137-58.trex-nlb.outbound.svc.cluster.local [100.126.137.58]) (Authenticated sender: yszpovajlk) by relay.mailchannels.net (Postfix) with ESMTPA id 55B498A4818; Sat, 26 Jul 2025 11:29:33 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1753529373; a=rsa-sha256; cv=none; b=jquujoNZ/bkUdTc0s8AlBephCaPy0o1ypR/ubaSapdji+uE9eq3oRUy6qmGW5aJCjeLwxl 0WkV2jrR4jpmJQkHkENhrKqllcWweXXdpTa+Bplmkv2dvoPowYWDmtztlzctyd3YzivZwi Biz4sigc8RVHozYX5iK6UXPr7IifEZvhN/5DpMadmVEyWOaV0aVGo3Uq3lP432HXPJRdCN VuIP1exDUJXMy5S2+OS44ghU/UBkdDXLRrND2otQhaqxW5yH2XTuneqE2UywcyTyLYdaJM o6Tud9ZfHe97abAQGeDlyKfXy3zJy/u0NghuIrTLiCLRyk79DGnLiiJ51qO7cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1753529373; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Xz0kFWAVWAQQGLBs72nL90/RtuymHatKkJlQEWSkjHw=; b=J4rVphWkCY6uWcVjussbIHkZFfxTjY0L9oIZNZmChjDIcfzR2ViT2U/wyMxCjlShoMm2Dd vCnRHGgGcN5ViLGIGiEPrP57jOLAfOm8aRD3rBmD68obbAT7sNaak0PQ8ZmZj3Yjaz7jaO s39tm52ragpJ/+YP5TRCzAi2JRWilQoMhQ1baIjZxjcHeUGltILVaTlPhorGRQEQlOLmfU TvTezHbvSUUPu0FS0yJLe7ZFFxG4QqvSs7kmRnOX/hHPOEyKXf3zpiZZBSLELYci0gw1bS py/5OAjsblJCC35naRdlLINn8tC7FMcqyvfRGHkBGdiqB8lOLJtU7/TINeF6SA== ARC-Authentication-Results: i=1; rspamd-696f8998d-jwl79; auth=pass smtp.auth=yszpovajlk smtp.mailfrom=juris@glaive.pro X-Sender-Id: yszpovajlk|x-authuser|juris@glaive.pro X-MC-Relay: Neutral X-MailChannels-SenderId: yszpovajlk|x-authuser|juris@glaive.pro X-MailChannels-Auth-Id: yszpovajlk X-Soft-Unite: 5a4416186f75c7a0_1753529374597_305102120 X-MC-Loop-Signature: 1753529374597:3792244703 X-MC-Ingress-Time: 1753529374597 Received: from server52.areait.lv (server52.areait.lv [83.149.95.205]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.126.137.58 (trex/7.1.3); Sat, 26 Jul 2025 11:29:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=glaive.pro; s=default; h=Content-Type:MIME-Version:Message-ID:Date:Subject:In-Reply-To: References:To:From:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=/0FkZZTEQXaSPaSmyx2rAlMi9Bwd9HzAiVQfs7ewvg0=; b=Auj/wraP7R2crLE2JKTFValnio aV4E1sinnKDyH9RhzGZEjQhBiTVtk1mypXXuO6VQhIoMiFiuSatSed8j9vZ373JIePAcu8QuOkGiN dpHMVapWigBcfsA1w6ChaKKu4E9AbOmbTclRj5iNgcBZ+zK7HQtKuw5rMDjPJXgiABRjpaXiIPlFn iiJzIW0zlFzyPq12bbTFY/HcXtwINNyN/EsIYt8tE6Qn9a3j3Abc+hUb7YJpt2ExsKIPzNuwOZiOb 9QPX6OPoM0zgSt1UTnTve5G9e5zIsfl7IK6lTtoMEHU9NOevCLhMxrEcjASCSDlA8ZWVw58kRPEhp AhrjUxmg==; Received: from [77.93.29.116] (port=65180 helo=LAPTOPHKIOPCGI) by server52.areait.lv with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1ufd5o-0000000FdSZ-2ne9; Sat, 26 Jul 2025 14:29:31 +0300 To: "'Daniel Scherzer'" , "'php internals'" References: In-Reply-To: Subject: RE: [PHP-DEV] Validating #[\Attribute] targets Date: Sat, 26 Jul 2025 14:29:30 +0300 Message-ID: <010c01dbfe20$8ddad8e0$a9908aa0$@glaive.pro> Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_010D_01DBFE39.B328FB40" X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQFZ2k2ZJ46Rg5f6UjhMOotW0OmHibVIiOWA Content-Language: lv X-AuthUser: juris@glaive.pro From: juris@glaive.pro ("Juris Evertovskis") This is a multipart message in MIME format. ------=_NextPart_000_010D_01DBFE39.B328FB40 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hey, =20 > if you are not going to call ReflectionAttribute::newInstance(), then = you don't > really need to mark the trait/interface/enum/abstract class as an = attribute. =20 Personally I never knew the `#[\Attribute]` is only required to do = `->newInstance()`. =20 The docs make it seem like it=E2=80=99s a boilerplate to have an = attribute at all: = https://www.php.net/manual/en/language.attributes.overview.php And the documented example does not call `newInstance` although the = attribute is defined with `#[Attribute]`. =20 I=E2=80=99m also confused as the example created by Ilija = https://3v4l.org/8Lih3#v8.4.10 that would supposedly break does not = include `#[Attribute]` at all. But it includes an enum being used as = attribute without it using the label itself. So what would actually = break? Using enums as attributes or declaring them as such? =20 Btw while reviewing the docs = https://www.php.net/manual/en/language.attributes.classes.php=20 I noticed that =20 > It is recommended to define a separate class for each attribute. =20 Recommended as opposed to what other options? I don=E2=80=99t think I = can use a random string as an attribute without defining it, right? So = what is this recommendation steering me away from? =20 BR, Juris ------=_NextPart_000_010D_01DBFE39.B328FB40 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable

Hey,

 

> if you are = not going to call ReflectionAttribute::newInstance(), then you = don't
> really need to mark the trait/interface/enum/abstract = class as an attribute.

 

Personally I never = knew the `#[\Attribute]` is only required to do = `->newInstance()`.

 

The docs make it = seem like it=E2=80=99s a boilerplate to have an attribute at all: h= ttps://www.php.net/manual/en/language.attributes.overview.php

And the documented = example does not call `newInstance` although the attribute is defined = with `#[Attribute]`.

 

I=E2=80=99m also = confused as the example created by Ilija https://3v4l.org/8Lih3#v8.4.10 that would supposedly break does not include `#[Attribute]` at all. = But it includes an enum being used as attribute without it using the = label itself. So what would actually break? Using enums as attributes or = declaring them as such?

 

Btw while = reviewing the docs ht= tps://www.php.net/manual/en/language.attributes.classes.php =

I noticed = that

 

> It is = recommended to define a separate class for each = attribute.

 

Recommended as = opposed to what other options? I don=E2=80=99t think I can use a random = string as an attribute without defining it, right? So what is this = recommendation steering me away from?

 

BR,

Juris

<= /body> ------=_NextPart_000_010D_01DBFE39.B328FB40--