Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130788 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 78A321A00BC for ; Wed, 6 May 2026 21:33:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1778103208; bh=YezdSQ4FXh5BZatHbxxyf0taeDJhqb96mXIRS8jexOQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=nt/kiBvHQc/hmEpS/3POzgWQPtueq1H/+97BSfB3GMHFO+piSdaSJ8EU/mh/lPHoJ RX/BS6clpp7HebvzOhfcBssoSR9VD6FOvssdEILsjAj3u9KOIzAv1bsqeAK3MmUKaU KTBcvwRwAoeS+odxLgqEu7PPNhL9Q4O79aY3ljz+NoMZP1HDAx+V2yJ8QDoXdvnzoO koCiF93v3kP7ieyzcO1psgY6PVAPT8BfE4EDx4OJplT0OAGpU9098LZ9G6BHVfVY0E +r8EGKHzz5cdfPeink93NTv0CnS9BO0/caHfWigyPFxsjCg4eHI9zvB9ypb8pK47mh gbQqPvlsuyJ6Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4E1E118005D for ; Wed, 6 May 2026 21:33:22 +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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, T_SPF_TEMPERROR autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) (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 ; Wed, 6 May 2026 21:33:21 +0000 (UTC) Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-7bd5e373d07so1185007b3.2 for ; Wed, 06 May 2026 14:33:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1778103196; cv=none; d=google.com; s=arc-20240605; b=gZE8Efw9hIadkbrGYOq27+oPK3dw7xGVj0TsPnVVP883Vg2wqJ2bAO6KLHIYcVT+Mm 2L4VCs3AtdpJR5zE4waVNDnBMdXubM77aiJjeKt8RaYHBCpfkt9BltHc3N5gZ0io3c8U q1ikLsKRowMQMX7Ey4QXB7guhPoSvXAOzmGvIUvK3lMW/TadQlYuX+x82sJ7WCwm8nJF mtmKl/3wNM8xhhSRi8hf6v5/mQsOCsS2wtrmg8GZQdm2MzZ8WAgMUt9TnL4XA0dPxROd BaWzl4Ech7Zh2hFV9lqeMqz7+sdDp41n/DZTT//rr40zrvx+kKrnchxao5avly86fB+k S6aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=YezdSQ4FXh5BZatHbxxyf0taeDJhqb96mXIRS8jexOQ=; fh=DYT97RqsmUAHGDEpS0f7q28AxeObgzHh5lzdzGYZUM4=; b=fX40cjsUivMGwSzfWIqC3Co4jmI7Zs2WzKQEuJqMRuHoo8JEfqZQq2O9Y184CLqbIA W1LZAL7vjoM2v60YniUf87LizDm3ljLXybDJ034i2p5Klz9XaWeFiR/zVKxmU/rK9Ueb HCFNiPgLjbwv9eBHfqGpxxxGYRLcOAu3UN/Hg6/B9QI7bQexIu0Mfx7fCTXnGV73qObl +oqsitdzWIZyiPrM24PPFPwUQfrKFaGRBmjduNXu3ru4aAfUckkh4NV8w8cN2F2NfRle 9wUHpGnc+UutsgOnmNS8bYa6yByV9j+8tGikihzaCyYu4StZOzEQUUGX2kH4OC1c1lW1 TSfQ==; darn=lists.php.net ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778103196; x=1778707996; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=YezdSQ4FXh5BZatHbxxyf0taeDJhqb96mXIRS8jexOQ=; b=qVjUaR5P41CC0DwoKOx+C0J21n6umwGBDHpRZdWTw7UuXrY4ppfPOF7y8ig15vNhXj RpspSpLjgP91PqefA8tTOfsPGYxcAY5nui4ecl7h75UeSiEY86RRoETP5bz34ADFPFf0 Ac0Yq8pSy4Kz4/ZV+7ACKX9TLUC8xP0REBxHe51WRj8GLmdTlBGurRKjY40leaF5cLWI iuUpNoDTjAsOO3IXBWEIN/Z8SEvhFpBqGsJUCINEp+J8YdR5XtFJeea7gv/fqEVRX7qk bu9yRVy4e5Kmo1SnSeEObTPX/KxQxolHKurFtbibYthdc7ttjdg44dUJg1F9NQsc2iWo dHQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778103196; x=1778707996; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=YezdSQ4FXh5BZatHbxxyf0taeDJhqb96mXIRS8jexOQ=; b=Z8KJ0+OZFt40EVpWcN9MgkFaTw3jeKniTl2ZRxWr52P8zHGOUXp9WN4AaiWA44h3Qk TL3PZM1F+JCAMnVpmwGx5FRY6yVgrLtR9I82aq3nlFlkMYkTXBd9/udWIgsyLKYti6yx MMQQzroR8dkIjI5vDWA+Dj2O6fWeJwlRyMn1nGVJp6G/8aLDNBm6TVthguv2Aue7Qa4m 2U/MmJQo+WWSvJBXzFHvrYXKDDcNkppIpD32tOLbGvAfvqhcGutQ820dyKuXVamOQXs4 OF5dIIfWJBra1nc/CI4LAdZ2KISUShsZEHmbjKAbmBgQDbgJQTzVkitU2hvugiJd5liP ly/A== X-Gm-Message-State: AOJu0YyUmUWISDEt0zJW5eR5Ql58B9iS2iSXMCqMc3+ALDDP1HXptcbd A1ypcgsohGmVZY73B826XGAfB7/tsjIhG++M0q0cDSfsC7dKaYT+coQLXiN4Y2tdUbj2/ukwEJP n1MUWVkTAyCvXHxzZ81uO3uLB3lCaa0h70g== X-Gm-Gg: AeBDietA9iLlIKm+dRRaDFsL7H307ewo2rV+6WwS+PGMJdojWrv3qF/+Kt1qj2w1aAW U0ijVG/tBujnSHaV4cVIX6fUYktkEZWKuF+cqeJsEh5Ge53iwlshv2cfJmpXOkKF2j+Ge6PmWeW 1w+OivfjmfhYBPHg5ADQxtFrILXjTgrbO3sqRuAEpt/GroGfb15xkPqtW/GqOlK0nnCss7w3XEQ QnPlMgQLKDSpcT9aKLdzhFsvm+BDPTETeI3f8IBMKu9mlhYgaZ+ymvoEedQzQUgSJYgLQTctfa0 uMwGIirZmGyBPYOJ1w== X-Received: by 2002:a05:690c:d84:b0:7bd:8782:bb5d with SMTP id 00721157ae682-7bdf5e6680cmr55477107b3.25.1778103196144; Wed, 06 May 2026 14:33:16 -0700 (PDT) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 6 May 2026 14:32:43 -0700 X-Gm-Features: AVHnY4KJ4j-DjnUpNgzui_nIdQXjDSDcIn3irtqAaoskWTpjA7gy8gOgYiQlrI0 Message-ID: Subject: Re: [PHP-DEV] [RFC] [Discussion] Add ReflectionAttribute::getCurrent() To: Derick Rethans Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="0000000000006157e006512ce931" From: daniel.e.scherzer@gmail.com (Daniel Scherzer) --0000000000006157e006512ce931 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, May 4, 2026 at 2:13=E2=80=AFPM Derick Rethans wrot= e: > On 4 May 2026 21:24:39 BST, Daniel Scherzer > wrote: > >Hi internals, > > > >I'd like to start the discussion for a new RFC about adding a new method= , > >ReflectionAttribute::getCurrent(), to access the current reflection targ= et > >of an attribute. > > > >* RFC: https://wiki.php.net/rfc/reflectionattribute-getcurrent > > > "a new static method, ReflectionAttribute::getCurrent(), that, when calle= d > from an attribute constructor, returns a reflection object corresponding = to > what the attribute was applied to." > > This sounds like an arbitrary new rule for just this functionality. I > don't think we should have special rules for a single static method call. > > I believe it's useful to have something like this, but I'm not in favour > of this approach. > > Would it not be possible for this to be a normal (dynamic) method on the > ReflectionAttrbute object? > > cheers > Derick In order to reduce the scope of the weird new method, I have updated the RFC to split it up: * ReflectionAttribute::getCurrent(), when called from an attribute constructor, returns a *ReflectionAttribute* matching the usage (replacing the currently-possible hacking with backtraces) * ReflectionAttribute::getReflectionTarget() is a normal (dynamic) method returning the ReflectionAttributeTarget These are expected to be used together in the constructors of attributes, e.g. `ReflectionAttribute::getCurrent()->getReflectionTarget()`, but the normal getReflectionTarget() method is also useful and usable elsewhere. -Daniel --0000000000006157e006512ce931 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Mon, May 4, 2026 at 2:13=E2=80=AFPM De= rick Rethans <derick@php.net> w= rote:
On 4 May 2026 21:24:39 BST, Daniel Scher= zer <da= niel.e.scherzer@gmail.com> wrote:
>Hi internals,
>
>I'd like to start the discussion for a new RFC about adding a new m= ethod,
>ReflectionAttribute::getCurrent(), to access the current reflection tar= get
>of an attribute.
>
>* RFC: https://wiki.php.net/rfc/reflectio= nattribute-getcurrent


"a new static method, ReflectionAttribute::getCurrent(), that, when ca= lled from an attribute constructor, returns a reflection object correspondi= ng to what the attribute was applied to."

This sounds like an arbitrary new rule for just this functionality. I don&#= 39;t think we should have special rules for a single static method call.
I believe it's useful to have something like this, but I'm not in f= avour of this approach.

Would it not be possible for this to be a normal (dynamic) method on the Re= flectionAttrbute object?

cheers
Derick

In order to reduce the scope of the = weird new method, I have updated the RFC to split it up:

* ReflectionAttribute::getCurrent(), when called from an attribute c= onstructor, returns a *ReflectionAttribute* matching the usage (replacing t= he currently-possible hacking with backtraces)
* ReflectionAttrib= ute::getReflectionTarget() is a normal (dynamic) method returning the Refle= ctionAttributeTarget

These are expected to be used= together in the constructors of attributes, e.g. `ReflectionAttribute::get= Current()->getReflectionTarget()`, but the normal getReflectionTarget() = method is also useful and usable elsewhere.

-Danie= l=C2=A0
--0000000000006157e006512ce931--