Re: [RFC] Primary Constructors

From: Date: Mon, 29 Jun 2026 08:00:36 +0000
Subject: Re: [RFC] Primary Constructors
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-131567@lists.php.net to get a copy of this message
On 29/06/2026 07:31, Nick Sdot wrote:
If "use conventional constructors, if you need readonly classes" stands, then the same can be argued for everything else in the RFC.
For the record, my view is completely the opposite: if the new syntax allows everything a normal constructor does, just in a slightly different position, it will lead to endless style discussions of which to use. In fact, I don't think even property hooks belong in a primary constructor; they're ugly enough in a constructor promoted property. I think it's perfectly fine to have short-hands that only cover specific use cases, and longer forms that let you express more complex use cases. It's one of the reasons I voted against the recent RFC to allow an extra reassignment of properties in the constructor [https://wiki.php.net/rfc/promoted_readonly_constructor_reassign]. -- Rowan Tommins [IMSoP]

« previous php.internals (#131567) next »