Re: [PHP-DEV] [RFC] Primary Constructors
[email protected] (Seifeddine Gmati)
| Newsgroups | php.internals |
|---|---|
| Message-ID | <CAFyg4HiO4JVwtLAr9trncxEXNqio5tUFq0yL-pChV=DtMNgO3Q@mail.gmail.com> |
On Mon, 29 Jun 2026 at 01:18, Rob Landers <[email protected]> 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.