Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126901 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id E3BB41A00BC for ; Fri, 21 Mar 2025 19:30:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1742585260; bh=dd0EKajyDpGVjijWdZ5GXVydOS68R44NmU/f9u2/uPA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=C2GYZeLouWk6ETVxbnRb0rgL1yag2GOnhNSBkAW0s6xfdzeVpTvdYFfNaHiC5TpQe OzD8jLaK+2GIG1YzIOK6cbxg+7sLnT021rVRJV+HeA3MLdeu9QNKC6DTCCSaTea5M6 rO0tjXx2rFzvdBUTi3OPZzsn1YUW/JeClFwRLARhnnzqItHOjYNEburEcnaJLmV/JF ncE50/9n3Tvcko50o9+omGbE2VFpVwoj8lmYaeGSkzYPsauC66uGFVz3aWFqjU+Hnq PN7cvXsmniqVkO7v1Awwwh/wEnipbClWtaWjK6dCgZHZoQPpRWR4UfJYGRHXTar7Hp 4hcwAiEYZxdAg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C07C0180082 for ; Fri, 21 Mar 2025 19:27:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-vk1-f170.google.com (mail-vk1-f170.google.com [209.85.221.170]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 21 Mar 2025 19:27:36 +0000 (UTC) Received: by mail-vk1-f170.google.com with SMTP id 71dfb90a1353d-523f19d39d3so1155691e0c.2 for ; Fri, 21 Mar 2025 12:30:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742585406; x=1743190206; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=VYUd6OHlhWgbtwvPGv6b73hloz6Qy88B0Xajykdo9ng=; b=UmT3IM1qYFkkCw7ApGrftnICAqwv+AJznvExjpnik3guTx0y6M2hcTYbuVVzoatgQi 2CJXsY177mgKEk6rekKf2wLtqfPw9r9hLojc828VWpyt9g0SDE/6QMKtK5tgjbEZT5Yh VXEmjIBz9cNX8rbMJA1vPW+WDIbcMcPXnx13Xj7GYTh7dG0f9LLh8wM4Ke1f9Wvwb3cp kPVABEAtpUqg1evWuKAKmTt3kpLdsPtMcZyVpQkxv4VsgaLxbVEnXrN/OBL4JwmzKC1l C3RAVEA9dlmLeDsrC8AJYGQZ9SvMr5leH5HwR07tOr5/ZZ3FWOi31GnC3SbF/haKcx/x C78Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742585406; x=1743190206; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=VYUd6OHlhWgbtwvPGv6b73hloz6Qy88B0Xajykdo9ng=; b=ichHhydOIF22ycTq0IyUiZMOpZedAkklOuxtBLXnGgUH9K63kjwqv5mLl1w7D1YLFP HaR/cD/+x9O+c6mxgEY9gFBEcXVwgcNT1O6a+o8KEbhyYJNxdcMO0AYZfwzID7vjahvx EuWj9lU5rIOq9dOncPp7NDkTVmcmEjI0BOzHpRNR91clKFBBcNy3WWwmf7X1ns45fr6r nQZPP4Zfc7f4GYATRR5+M0NE6SyI1Fr27/mFTAVI3m6eL4JO1zJICyep/HFEx65ODfsV vpTV1QHqpLD8nkuej/Ekeey0zLLdv1Ik0c4jTv/v7p5FcRJ/BbyxCjz4e2eJyu5Qb8Gk EjAw== X-Forwarded-Encrypted: i=1; AJvYcCXLjvw5tGtGnudw65Ht57M9NSosJPbh5VvGkYMLV+Pc8c8PacGn16jG4Xk+Vnman72QXAjIt8PP3Xg=@lists.php.net X-Gm-Message-State: AOJu0YzdArXuq9g95nba0XCPIxj+WrncXkvod2+5sHO6acztuuR1hZY2 ifI2KKhvgE4aFPaFSWKRv62sEYXnA3GlOyLWA8VEvd/l06kr2PUUlq81txhi7XmiQXusSgjY5mg IYNdxUHGxuHq2kDPq5awPDnDfhwo= X-Gm-Gg: ASbGncviMuHDuvecbOOoAtJ9KXAHp+UX9wbX6uqYcwOUQXl3fFKZaTzPdd0r4xPMq7d qXAuUxu0iGgi7JHKASjoyRbQAWbGVIcPcsikbt8BSafOAd2Ej0anLNFRwFvQ93QcWllhf4zWH0G G++w42lHlRZhp81oIWbuGSQN8fLhk= X-Google-Smtp-Source: AGHT+IE0AOk80SbuYj9YlEfpCz/Hw7WckpKkhb9ltU8li8G/pWyo1zAiDY7esqdYn3vZjLYKGjTI0DbRgRW06mvr278= X-Received: by 2002:a05:6102:5493:b0:4bb:d45c:7f4b with SMTP id ada2fe7eead31-4c50d514d2emr4855358137.11.1742585406140; Fri, 21 Mar 2025 12:30:06 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <250fd68437fe3025e3aad9eff271dde3@bastelstu.be> In-Reply-To: Date: Fri, 21 Mar 2025 12:29:29 -0700 X-Gm-Features: AQ5f1JoASE2CYglNKCwvv7OQRWiXE6KcKwWT20mq-uxTFEgeDYwPmS_01J8JscA Message-ID: Subject: Re: [PHP-DEV] Re: Constructor property promotion for final properties To: =?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?= Cc: =?UTF-8?Q?Tim_D=C3=BCsterhus?= , internals@lists.php.net Content-Type: multipart/alternative; boundary="0000000000001fbb850630df4850" From: daniel.e.scherzer@gmail.com (Daniel Scherzer) --0000000000001fbb850630df4850 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Mar 21, 2025 at 9:45=E2=80=AFAM Alexandru P=C4=83tr=C4=83nescu wrote: > > On Fri, Mar 21, 2025 at 5:20=E2=80=AFPM Daniel Scherzer < > daniel.e.scherzer@gmail.com> wrote: > >> On Fri, Mar 21, 2025 at 4:07=E2=80=AFAM Tim D=C3=BCsterhus 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=C3=BCsterhus >>> >> >> 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 te= st >> 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 jus= t > to a property? > > -- > Alex > Sorry, I completely missed that part. Yes, that should trigger promotion, and if it doesn't then that is a bug in my implementation. When I retarget the PR to master I'll also add a test case for promotion from just using `final`. --Daniel --0000000000001fbb850630df4850 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

On Fri, Mar 21, 202= 5 at 9:45=E2=80=AFAM Alexandru P=C4=83tr=C4=83nescu <drealecs@gmail.com> wrote:

=
On F= ri, Mar 21, 2025 at 5:20=E2=80=AFPM Daniel Scherzer <daniel.e.scherzer@gmail.com> wrote:
Can you clarify if the following woul= d result in constructor property
promotion or not:

=C2=A0 =C2=A0 =C2=A0class Foo {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0public function __construct(
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0final string $bar,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0) { }
=C2=A0 =C2=A0 =C2=A0}

Best regards
Tim D=C3=BCsterhus

Yes, that would resu= lt in constructor property promotion. I'll need to retarget the origina= l PR for master, but at=C2=A0https://github.com/php/php-src/pull/17861 you= can see in `Zend/tests/property_hooks/final_prop_promoted_2.phpt` a very s= imilar test case.


I see. Good catch Tim.
Daniel, you don't have this ex= act test case there.

Initially, in 8.0, only a vis= ibility keyword would trigger the property promotion logic.
Later= , in=C2=A08.1, also the readonly keyword would trigger this and make the pr= operty public, without the need to mention the visibility:=C2=A0https://3v4l.org/Co0gl
<= div>
Now we want the same for the final keyword, to trigger t= he property promotion without having a visibility keyword,
becaus= e=C2=A0like readonly, it would not be applicable=C2=A0to a parameter, but j= ust to a property?

--=C2=A0
Alex

Sorry, I completely missed that = part. Yes, that should trigger promotion, and if it doesn't then that i= s a bug in my implementation. When I retarget the PR to master I'll als= o add a test case for promotion from just using `final`.

--Daniel
--0000000000001fbb850630df4850--