Hi Nikita, śr., 3 mar 2021, 16:04 użytkownik Nikita Popov <[email protected]> napisał:
> Hi internals, > > I would like to propose allowing the use of "new" inside various > initializer expressions: https://wiki.php.net/rfc/new_in_initializers > > In particular, this allows specifying object default values for properties > and parameters, and allows the use of objects as attribute arguments. > > The RFC is narrow in scope in that it only adds support for "new". An > extension to other call kinds should be straightforward though. > The reflection mechanism for properties, constants and parameters is not described in RFC but I do believe it should for constants part. Correct me if I'm wrong there. The reflection for ReflectionProperty::getDefaultValue the same for ReflectionParameter is similar and I get that it possibly should evaluate the value on each call. But what about constants which by their nature don't change? Does that mean that each time ReflectionClass::getConstant is called the value is already evaluated and the return value always refer to the same object instance. Is that right? I guess it is. IMO it deserves to be described in the RFC. In general I love the proposal was especially thinking of it for static variables. Cheers, Michał Marcin Brzuchalski >
