Re: [RFC] [Discussion] Attributes on compile-time constants

From: Date: Tue, 03 Dec 2024 14:40:42 +0000
Subject: Re: [RFC] [Discussion] Attributes on compile-time constants
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-126098@lists.php.net to get a copy of this message
On Mon, Dec 2, 2024 at 2:48 PM Tim Düsterhus <tim@bastelstu.be> wrote: > Thank you for your RFC. As you might have guessed from my comments on > the PR, I quite like the proposal to round off attributes. Nevertheless > any new syntax has quite a bit of an impact on tooling around PHP (see > also (3) below), so I'm curious if you already have any use cases > besides the #[\Deprecated] attribute that could be mentioned in > the > RFC text? > I don't have any other use cases at the moment - my primary motivation in writing this feature was to allow deprecating constants. A few weeks ago I gave a talk[1] where, among other things, I talked about how I was looking forward to using the #[Deprecated] attribute, but that there was still room for improvement since it could not be used on non-class constants. I then figured: why not try to implement that support myself? And I eventually figured it out. > This is a non-issue, because the Attribute class is final. > Fixed, thanks > This is not just extensions, but also userland code that did not > anticipate any new attribute targets. > Given that 1. there isn't (as far as I know) a way to search for everything that has an attribute 2. there isn't a current way to identify if a constant has an attribute I didn't think there was anything to actually break for userland attributes, but I've reworded the note to include userland attributes just in case. The “Backward Incompatible Changes” section should probably shortly > mention that this is new syntax and will need changes to IDEs, static > analysis tools and formatters. The second paragraph in > > > https://wiki.php.net/rfc/closures_in_const_expr#backward_incompatible_changes > might be a good example. > Done -Daniel [1] https://youtu.be/hGYbXkfbkuU

« previous php.internals (#126098) next »