On 16/03/2023 17:59, Nicolas Grekas wrote:
We could define the "use" as declaring + setting the properties before
the constructor is called, if any.
But I'm also fine making both constructs conflict: when there is a
constructor, the boilerplate saved by the "use" becomes really low.
No strong opinion either. There could be other factors to consider.
The main advantage of generating an actual constructor is that no change
is needed to the shared object initialization code, which could be
complex and even have performance impact. The only new logic would be in
compiling the class entry and putting the arguments into the "new
class(...)" statement.
The more I think about it, the more I'm leaning to just blocking custom
constructors, and saying you can either have the use() short-hand, or
you can have custom initialization. Additional functionality can always
be added in later if someone comes up with a clean implementation and a
good use case.
Regards,
--
Rowan Tommins
[IMSoP]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php