Re: [PHP-DEV] [RFC] Readonly Property Defaults

[email protected] (Tim Düsterhus) Mon, 13 Jul 2026 20:30:51 +0200
Newsgroups php.internals
Message-ID <[email protected]>
Hi

On 2026-07-13 20:21, Nick Sdot wrote:
> Got it. Yes, no specialities. In case you deem it necessary I could add 
> an assertion to an existing test. Something like:
> 
> ```
> class Foo { public function __construct( public readonly string $a = 
> 'bar') {} }
> var_dump(new 
> ReflectionClass(Foo::class)->getProperty('a')->hasDefaultValue()) // 
> bool(false)
> ```
> 
> To me it feels just not too related, and in other reviews I got 
> commented for over-testing.
> But up to you. Feel free to let me know.

I don't think an extra test is necessary. I just want to be able to 
point folks who will inevitably run into this and raise bug reports to 
an official document that says “we thought about this, this is working 
as expected” :-) It will also be useful for the migration guide and any 
other blog post about “what's new in PHP” (particularly the less 
well-researched or AI-written ones).

> Maybe "no specialities" can "promote" you from team abstain to team 
> yes. ;)

Personally I've never had a desired to have this capability, so it will 
remain an Abstain from me to leave the decision to folks who would 
actually make use of it.

Best regards
Tim Düsterhus