Re: [RFC] Primary Constructors
| From: | Tim Düsterhus | Date: | Wed, 01 Jul 2026 08:19:31 +0000 |
| Subject: | Re: [RFC] Primary Constructors | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-131648@lists.php.net to get a copy of this message | ||
Hi
Am 2026-06-29 21:07, schrieb Tim Düsterhus:
Am 2026-06-29 02:17, schrieb Rob Landers:The RFC also doesn't specify whether the parent constructor call supports named arguments:I'd like to put forward Primary Constructors <https://wiki.php.net/rfc/primary-constructors> for comment.The RFC currently does not specify the interaction with visibility. It is currently implied that the constructor will bepublic, but the RFC doesn't spell that out and doesn't specify whether or not it is possible to make such a constructor non-public (e.g. to actually treat it as a “primary constructor” in a sea of multiple named constructors).
class P(public string $foo, public string $bar) { }
class C(string $bar, string $foo) extends P(bar: $bar, foo: $foo) { }
Best regards
Tim Düsterhus