Re: [PHP-DEV] [RFC] Primary Constructors

[email protected] ("Rob Landers")
Newsgroups php.internals
Message-ID <[email protected]>
Hi, Nick,

On Mon, Jun 29, 2026, at 10:47, Nick Sdot wrote:
> Hey Rowan,
> 
> On 29.06.26 16:00, Rowan Tommins [IMSoP] wrote:
> > 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.
> 
> 
> That's a fair opinion, and not unexpected. Personally, I oppose 
> introducing more inconsistencies to PHP. Looks like that we need to have 
> these discussions then?

There's no inconsistency here. This syntax doesn't prevent you from using readonly classes. It only prevents you from initialization/validation in a body because there are no bodies. If you need a body, use a constructor -- that's what they're for. The RFC makes it plain that bodies are rejected and why. If you can provide a concrete reason why they should be allowed with a completely new syntax, that would be a good follow-up RFC; or even a competing one. If you disagree with the reasoning, I'd love to hear it.

— Rob
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.