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

[email protected] (Tim Düsterhus)
Newsgroups php.internals
Message-ID <[email protected]>
Hi

Am 2026-06-29 21:07, schrieb Tim Düsterhus:
> Am 2026-06-29 02:17, schrieb Rob Landers:
>> 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 be `public`, 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).

The RFC also doesn't specify whether the parent constructor call 
supports named arguments:

     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
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.