Re: Re: Constructor property promotion for final properties

From: Date: Fri, 21 Mar 2025 16:45:08 +0000
Subject: Re: Re: Constructor property promotion for final properties
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-126900@lists.php.net to get a copy of this message
On Fri, Mar 21, 2025 at 5:20 PM Daniel Scherzer <daniel.e.scherzer@gmail.com> wrote: > On Fri, Mar 21, 2025 at 4:07 AM Tim Düsterhus <tim@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

« previous php.internals (#126900) next »