pon., 17 maj 2021, 16:02 użytkownik tyson andre <tysonandre...@hotmail.com> napisał:
> Hi internals, > > I've created a new RFC > https://wiki.php.net/rfc/enum_allow_static_properties > > Although enums are immutable objects, it is often useful to have functions > or methods that operate on enum instances. > In many cases, it would make sense to declare that functionality as static > methods on the enum itself. > In cases where static methods require shared state, it would be useful to > allow storing those shared state in static properties. > To ensure immutability of enum instances, it's only necessary to forbid > instance properties, but all properties were forbidden in the initial > functionality included with the enums RFC. > > This RFC proposes allowing static properties in enums, while continuing to > forbid instance properties. > Would you be able to provide more real life example? The example in RFC could easily encapsulate current Environment reading in for eg. EnvironmentConfiguration class with static property and method and TBH possibly that would be my preference to solve this. Cheers, Michał Marcin Brzuchalski >