Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126190 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 313C11A00BD for ; Mon, 30 Dec 2024 20:41:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1735591112; bh=VliI36c+raQrmfBB7sJx6Xq9RsJ3MEn+/RLJIleyvh8=; h=Date:From:To:In-Reply-To:References:Subject:From; b=OSQabS3QfRhCJVKKPelVI2x985LoKgD4Ay6mC88TovPA2Dyx/LgxLxsAssUoPgpA8 LLrbH7FtavxOBbkwbDfi3SWWvVngZkSZ0WU6Jo4/ZVjYFeEmrVQeCIDtNA8amzNX94 bzarYqxdbpvCOldlj87FaM1iQd7dvYyJQ28BqmArjY4N/9p15eenFWD0wS3jcLecjC B2kCqBbR2BtVIfr5oN9DOkSi5EcjepLHA++AHjs1B094RtlGnLnsjRGUXznSeZGQyN FU2P91p+Y8/feknuba/kWZgseYrhx5PsdBEN9p6cbz/Lc/+lZHZWSq2QYs9+Ju2t2I MOYC19um/lxAg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1BC2518007B for ; Mon, 30 Dec 2024 20:38:31 +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=-0.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fout-a4-smtp.messagingengine.com (fout-a4-smtp.messagingengine.com [103.168.172.147]) (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 ; Mon, 30 Dec 2024 20:38:30 +0000 (UTC) Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfout.phl.internal (Postfix) with ESMTP id 0F9F7138021C for ; Mon, 30 Dec 2024 15:41:28 -0500 (EST) Received: from phl-imap-06 ([10.202.2.83]) by phl-compute-01.internal (MEProxy); Mon, 30 Dec 2024 15:41:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to; s=fm2; t=1735591288; x=1735677688; bh=KDJlMBz+mzMnbCTvFhwq+ zbAiUj5V+CnX5DLlucJfcg=; b=H2bTVXRkphB94fFdFhq28WvvdfMEzWCTGgpNU iGar8agi+Kt4r7WnIpOaOV4Du93faFEL2TPxxDE8fEMj3pwWsNxzzU0MTbfdVB0o 6zdTpFViVZAe+39vRN1AjfbLpynVEuiP4TYZFlsx+Q4DWpO+MlopRWkOZDV5Fw+j FJVBsvJMpsHUEW4kE31N7cn7iGjX5iId8JchaPi7T9hX3A8ZH+BptU8Kz2rOkrA2 PwJi+DMLGIZl8Yi+lbsKm1usvA5wFo23Em5WtHvDlPh/xaoB8qRW3SCMemIyEZSD LXycHidmP2pll5aiClixiB19U7Lu7W9HIvI6hw3cC15+ZRAmw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1735591288; x=1735677688; bh=K DJlMBz+mzMnbCTvFhwq+zbAiUj5V+CnX5DLlucJfcg=; b=XA+YVwLiLxiW9u1J3 mZ3zI5ESKSA3gk6rzEkkgWxsNvgx8obgNZkGJJFaV1XoI/UVD5wVKtZc/2imRtQp NlyHTEP6GEVNF20TGiNRDYGwSw+j9eawEGR2qlcMh0ikjDl9pyU1/XVoxpAcQ4AG PbluEv+hOczfnoL+QVyr2HcFd2Q/J5e3U2BcUr3Hs7AD0kEAJZ3kxymPFKXksvUk SqCTSGXxXej1pv/LS257lY0NVVE851XrqIb/R4+OdjB+la/kKqvBEt6e8kA+qtl2 fVPBZUhe6rws7l9zu/Ol+50D5f3GTL8w1i/cBYv8PUNh2jjjDVo3Yz0hHDZnCa/B 20hHg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddruddviedgudegvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefoggffhffvkfgjfhfutgfgsehtjeertdertddt necuhfhrohhmpedfnfgrrhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfh hivghlughtvggthhdrtghomheqnecuggftrfgrthhtvghrnhepledvfeekfeevieekueel kedvvdelveeutdegieeiheeugfegffdtkeevieehgedtnecuffhomhgrihhnpeefvheglh drohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhm pehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomhdpnhgspghrtghpthhtohepud dpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepihhnthgvrhhnrghlsheslhhishht shdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 9B2DD29C006F; Mon, 30 Dec 2024 15:41:27 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Mon, 30 Dec 2024 14:38:29 -0600 To: "php internals" Message-ID: <5feef89e-9476-46f7-8a0b-9e7df17089bc@app.fastmail.com> In-Reply-To: <18eebe54-569d-4300-9e9f-4511ca9a60df@jnvsor.net> References: <0addc1b4-1e4d-45a9-a289-5f9a8e1da692@app.fastmail.com> <6bb0b82c31051ddf4c970ade616d532f@bastelstu.be> <18eebe54-569d-4300-9e9f-4511ca9a60df@jnvsor.net> Subject: Re: [PHP-DEV] [RFC] Static property asymmetric visibility Content-Type: text/plain Content-Transfer-Encoding: 7bit From: larry@garfieldtech.com ("Larry Garfield") On Tue, Nov 26, 2024, at 3:42 PM, Jonathan Vollebregt wrote: > On 11/26/24 9:35 PM, Larry Garfield wrote: >> Thinking aloud, my expectation would be that it behaves similarly to how final static methods would behave. Which appears to be a syntax error: https://3v4l.org/j8mp0#v8.4.1 >> >> So, shouldn't properties do the same? > > Without final you can still override both private static properties and > private static methods: https://3v4l.org/MS73Y#v8.4.1 > > When explicitly declared final, static properties do result in a syntax > error: https://3v4l.org/fqI8v#v8.4.1 > > Re-reading the logic in the original aviz RFC makes me think implicit > final here is unnecessary. All static properties are "Shadowed" like > private properties (even when they're public) so there's no conflicting > behavior. > > The two behaviors described as conflicting in the aviz RFC are decided > explicitly in the context of static properties, by the caller accessing > it with `self::` or `static::`. Not by a combination of the visibility > and child classes. > > Consider this example: > > ``` > class A { > private(set) static int $a = 1; > > public static function test(int $val) { > static::$a = $val; > } > } > > class B extends A { > private(set) static int $a = 2; > } > > B::test(3) > ``` > > Yes this would produce a fatal error, but doing this with just `private > static` does the same in current PHP: https://3v4l.org/Y6lZ7#v8.4.1 > > You might want to discuss banning use of `static::` on private statics, > but that's a big BC break. > > Since static properties do still have to have equal or wider visibility > when extending I'd say using `static::$prop` on a property you know is > private is a known risk and remove the implicit final. > > - Jonathan Hi folks. Finally getting back to this thread. Ilija and I have discussed it, and it seems to us that the consistency of implicit-final-on-private-set (on both object and static properties) is more valuable than maximal flexibility, especially as we're dealing with a rare use case to begin with. Specifically, `static::$prop` is still expected to behave the same as the parent class's $prop. Eg, its type can't change, its visibility cannot be narrowed, etc. So a private(set) parent $prop would violate that expectation, the same way it would for a dynamic property. Introducing another subtle difference between self:: and static:: doesn't seem like a good thing for DX. Additionally, if we find in the future that it really would be better to not have the implicit final and allow people to "opt in" via self::vs static::, it's less of a BC break to remove the implicit final in the future than to try and introduce it. For that reason, we are going to keep static properties consistent with object properties in this regard. --Larry Garfield