On Fri, Mar 21, 2025 at 5:20 PM Daniel Scherzer <daniel.e.scher...@gmail.com>
wrote:

> On Fri, Mar 21, 2025 at 4:07 AM Tim Düsterhus <t...@bastelstu.be> wrote:
>
>> Can you clarify if the following would result in constructor property
>> promotion or not:
>>
>>      class Foo {
>>          public function __construct(
>>              final string $bar,
>>          ) { }
>>      }
>>
>> Best regards
>> Tim Düsterhus
>>
>
> Yes, that would result in constructor property promotion. I'll need to
> retarget the original PR for master, but at
> https://github.com/php/php-src/pull/17861 you can see in
> `Zend/tests/property_hooks/final_prop_promoted_2.phpt` a very similar test
> case.
>
>
I see. Good catch Tim.
Daniel, you don't have this exact test case there.

Initially, in 8.0, only a visibility keyword would trigger the property
promotion logic.
Later, in 8.1, also the readonly keyword would trigger this and make the
property public, without the need to mention the visibility:
https://3v4l.org/Co0gl

Now we want the same for the final keyword, to trigger the property
promotion without having a visibility keyword,
because like readonly, it would not be applicable to a parameter, but just
to a property?

-- 
Alex

Reply via email to