Re: [RFC][Under discussion] Fetch properties in const expressions

From: Date: Wed, 22 Jun 2022 18:55:22 +0000
Subject: Re: [RFC][Under discussion] Fetch properties in const expressions
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-118062@lists.php.net to get a copy of this message
> Le 17 juin 2022 à 00:46, Ilija Tovilo <tovilo.ilija@gmail.com> a écrit : > > (...) > > Since the primary motivation of this RFC is to allow fetching the name > and value properties of enums I'm inclined to forbid using -> on > anything but enums. That would circumvent the issue since enums can't > contain user-defined properties nor the magic __get method, and > name/value are readonly. > > I'll take a few days to think about the options, and will update the > RFC and inform the mailing list about the decision I have made. Let me > know if you have any more thoughts. > Hi, I feel that, in any case, allowing unrestricted fetching properties in const expression in is semantically incorrect, because properties are fundamentally mutable. I am not speaking of creative use of code in order to achieve the effect, but of the regular semantics of properties. For me, it seems reasonable to restrict the feature to readonly properties (including those of enums), because those are effectively immutable by design. —Claude

« previous php.internals (#118062) next »