On Thu, 13 Feb 2025, Tim Düsterhus wrote: > Am 2025-02-13 09:16, schrieb Jakob Givoni: > > > Attributes were added as a structured replacement for docblock props > > and I don't like it when they affect how a program actually runs (as > > long as you're not using reflection). > > Excluding the `#[\Attribute]` attribute, PHP currently has 5 native > attributes and they all affect how the program runs. The initial > accepted Attribute RFC even lists several “behavior-affecting” > attributes in the “Use Cases” section: > https://wiki.php.net/rfc/attributes_v2#use_cases. It is probably fair > to say that use-cases like `#[\NoDiscard]` do not go against the > vision intended by the Attribute RFC. > > You could think of it as the PHP engine using Reflection internally to > do something differently.
I don't agree, but for a different reason. None of the current attributes (ReturnTypeWillChange, AllowDynamicProperties, SensitiveParameter, Override, and Deprecated) change the behaviour of how a program runs. They only add warnings. with the exception of AllowDynamicProperties to be an actual 'feature' in PHP 9.0 (now it's only a deprecation warning silencer). That's the same with this suggested NoDiscard, it doesn't change how a program is run — it merely adds a warning. cheers, Derick