I don't think the way it is going to be realeased is elegant solution On Sat, Jul 17, 2021, 2:47 PM Andreas Leathley <a.leath...@gmx.net> wrote:
> On 16.07.21 09:06, Nikita Popov wrote: > > We cannot make properties readonly by default, because that would be a > > major backwards compatibility break. > > > > If you're going for brevity, something you can do is omit the visibility > > specifier, as it is public by default. "readonly int $prop" works. > > Would it be possible to adapt constructor property promotion to support > this (as far as I tell, it currently does not)? Namely: > > class A { > public function __construct( > readonly int $id, > ) { > } > } > > According to the constructor property promotion RFC, the promotion only > happens when public, private and protected is used for an constructor > parameter. With the readonly RFC accepted, it would make sense to also > do constructor property promotion when readonly is used, to avoid the > explicit public, because readonly would also clearly define the > parameter as not-only-a-parameter. > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > >