On Mon, 29 Jun 2026 at 01:18, Rob Landers <[email protected]> wrote:
> Hello internals, > > I'd like to put forward Primary Constructors > <https://wiki.php.net/rfc/primary-constructors> for comment. > > An implementation PR will be opened later today (UTC), and the RFC updated > with this discussion thread. > > — Rob > I think this would be a great addition to PHP. There has been a few times in my career where I have needed to extend a 3rd party library and calling `parent::__construct($params);` at the end of my extending class always felt dirty. Being able to use ``` class MyClass(int arg1, string $arg2) extends Base(string $arg2) {} ``` Is much better, and clearer. It can avoid mistakes where a developer extends a class, doesnt call the parent constructor, it works but the base class might not be correctly initialized and might break down the line in production. Having an explicit "this get passed to the class we are extended" in the definition would wipe out that headache area.
