Re: [RFC] Primary Constructors

From: Date: Mon, 29 Jun 2026 18:54:47 +0000
Subject: Re: [RFC] Primary Constructors
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-131606@lists.php.net to get a copy of this message
On Mon, 29 Jun 2026 at 01:18, Rob Landers <rob@getswytch.com> wrote: > > Hello internals, > > I'd like to put forward Primary Constructors for comment. > > An implementation PR will be opened later today (UTC), and the RFC updated with this discussion > thread. > > — Rob Hi Rob, Personally, I really dislike this feature. It adds a new syntax that increases the complexity of the PHP grammar, which is already quite complex, for no real advantage. It's just a slightly different way to write something the language already expresses. It's also confusing to read. A line like: ``` class Foo(public int $a, public string $b) extends Base($a, $b) { ... } ``` jumps from class definition, to constructor definition, to class definition again (inheritance), to what is effectively a parent::__construct() call, and then back into the class body. That's a lot of distinct concepts packed into a single line, with no syntactic separation to signal the shift from one to the next. Cheers, Seifeddine.

« previous php.internals (#131606) next »