Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126900 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 52F4C1A00BC for ; Fri, 21 Mar 2025 16:45:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1742575378; bh=HtdXbrsNpDCWv2/u5p3mthS0OKdgEdQEI2FSBylN4FA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=j6ULp5fohmLcOnc+m2kXWSh4OKNbqSq52y8jNIczdBqre4Nahbw0K8YDl+UY+HWyd fdbiziwqZUUycO8j9IqoK+Fn6OLA7+DocIeFmIeoqDl2g4Bn6l7zT1ltRKWrNMqr5Z QX+j5dSrhcLYSk6mwJOdYikjst5d9qEGTHCwP+8S2eJB/hi+2smA//G1R85LJ0tWpa Hr9UMVXTN756kdFf1N45srFSYpScEhWL/qvfOYZRCA0GDdkBgbXeCf8wM52Jm39AyJ CDdBnyzH4M51PddVbceb0ohzhdQO4k0cv1lUhVPC/aFQmK/GTuGQZZLiZja30Pb28o ZLvRT68V+QrzA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C94FA180053 for ; Fri, 21 Mar 2025 16:42:57 +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=-1.2 required=5.0 tests=BAYES_50,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-yw1-f169.google.com (mail-yw1-f169.google.com [209.85.128.169]) (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 16:42:57 +0000 (UTC) Received: by mail-yw1-f169.google.com with SMTP id 00721157ae682-6ef60e500d7so17719737b3.0 for ; Fri, 21 Mar 2025 09:45:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742575527; x=1743180327; 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=ui9Om2NIZ7dKtqM/HqLBq/QOiTMiH7aC5+k+MF0rC/g=; b=KNkR3z7HPqrgpax2FCCyHpHX9oUYZOaE6cA+aBd454jI2Y384HUZZTuyq6S9So+SXL Dbn/SzKiVk7RazJDK/AOTQxxiURd52FvdrOtWRkIsEJIj52q1cf3HdZkRtP5tx/7P1eD Hto/gp7Ap0knyySvbr3FvLyGDOVKeyv6LVfmo7PcxSm3Of7WiWUEvwLs+bHmtjoYsR7V poCklndmdesNYfelR/CyEPaevQWHkLbsW0JMWf/fqrok0OsIVMy4IWowxCfObjTp69J3 v8GPRtt5SWHPXecPBGQ7wkfgB5froXEc6hJjCqtpqwVPAZ/dNvvg6uob1fbHhwe7MuC3 kEYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742575527; x=1743180327; 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=ui9Om2NIZ7dKtqM/HqLBq/QOiTMiH7aC5+k+MF0rC/g=; b=o7Bnc7nHaibBiZ9PZHY7pYVK4BUIWQa5SW9bUFxPJZ/HdHN2fN2Qytsv8e4NZRc2XY 5/UkZe85pd8+sVH3dkatty+HspaHJpnuaiNXE/aba+q25g5omuM7hqkUypa2q5EU/g/I sBIagOie7zgaFmmntFZtuBGgtiFJ4OijateVQIvG9adRIbeINxMt1h7B1tuFXGTpNkaY T1EA9+nY7kYt2Cfl0JtzwBh6qjWUk7UlKMPBuft+MPfTg5DVYv2keQYDFxv6RYHv2NYz yloJ9YCD0eppPnTYukswSm8gxJq38uv3hjz77ffQuWRdk4NheF6dkghaizarmLeBPmog 4wHA== X-Forwarded-Encrypted: i=1; AJvYcCWjCUIcjJwCMgOrrrX9eUfEGG1rcSIDj/JZXzrIUuROJF8svllqajgD9YeRWj4IiwM9GAhYY55NKps=@lists.php.net X-Gm-Message-State: AOJu0Yzp1zsPF5L6inyrVuAAuacx45W+Xix7lSu6lRTsCYTbUdK4/JaN OCkWiPz8dtganPfGBGwQeQMRXMPYtzj8OZWnvoIDEk4jTFw5PFIRsHqzQ7s6ATbCYBkvxEGFf82 THevP9wrMW05UA80h9lltxUz+29s= X-Gm-Gg: ASbGnct1ec2SjKKUnIaHmMb2J/99w/3Gt1YFEUIDz//pfDJfNCz2tnXahVW0uHOvP0s STD0RQNHVqrGHp80MBwNZYqhFtLiSrVw8Lw1vm+VstaQYSY4JNOfPjcT/90iIICpd6NZRyc8cHP E7z4NUj6ERLJ957+Z2go1vt//rSws= X-Google-Smtp-Source: AGHT+IGw4jMX+JjoaerllC4GypLR7UxPi9NDHyqjbr6B9cMTdZ4CbnWy9pAmN7Wbg1yv5J7gwXLO+tcDh/BJeXf/V2s= X-Received: by 2002:a05:690c:7201:b0:6fe:bfb9:549c with SMTP id 00721157ae682-700babeb60emr55528977b3.1.1742575527071; Fri, 21 Mar 2025 09:45:27 -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 18:45:08 +0200 X-Gm-Features: AQ5f1JqU5wBzI-MO26zFv7FSZy1GN9PWzOpoP6V-0v90vL0lW9PGbS8Kz-izztM Message-ID: Subject: Re: [PHP-DEV] Re: Constructor property promotion for final properties To: Daniel Scherzer Cc: =?UTF-8?Q?Tim_D=C3=BCsterhus?= , internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000491d1a0630dcfb76" From: drealecs@gmail.com (=?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?=) --000000000000491d1a0630dcfb76 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Mar 21, 2025 at 5:20=E2=80=AFPM Daniel Scherzer 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 tes= t > 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? --=20 Alex --000000000000491d1a0630dcfb76 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

On Fri, Mar 21, 202= 5 at 5:20=E2=80=AFPM Daniel Scherzer <daniel.e.scherzer@gmail.com> wrote:
O= n Fri, Mar 21, 2025 at 4:07=E2=80=AFAM Tim D=C3=BCsterhus <tim@bastelstu.be> wrote:
Can you clarify if the following would 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

Now we want the same for the final keyword, to trigger the property promot= ion without having a visibility keyword,
because=C2=A0like readon= ly, it would not be applicable=C2=A0to a parameter, but just to a property?=

--=C2=A0
Alex
--000000000000491d1a0630dcfb76--