Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127186 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 765FC1A00BC for ; Thu, 24 Apr 2025 19:26:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1745522672; bh=6edeLzEBWMstSroW3gM5vHjWuZ15PU8qLr0Q+G399KE=; h=Date:From:To:In-Reply-To:References:Subject:From; b=jAf1e7Rz033ZFc+sG/pygrkMK9Dm825+fL1RpWW9NzDt6U9x4xlLmNroNBXUmsroT K7IfDW8chPr7kIHxlSRpVdMfEE0hxrmH9aZV3lmgFkdN5kuN9L4EmgXyZCc7N13l+b J53G7o+DkQFAKEJPdKnat7F/qK3LFfjnt06husRpbiYzkETmyGRi5Ad8t1oShnyaxf goly0BlcTpg1q6QP9EoXsENo3w7oz+uAwtWHePIMqcDlF4YaNBXS3YZakKCDsA7f6U IWwKYD7Mo5eCQ1IzchKP0zYK3s/neSQJdXzIRgeJAzpuKtDWtGz0gqv5ES4egW3CnM X+BPo2/hcC6Dw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2604F18007D for ; Thu, 24 Apr 2025 19:24: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=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from fhigh-a1-smtp.messagingengine.com (fhigh-a1-smtp.messagingengine.com [103.168.172.152]) (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 ; Thu, 24 Apr 2025 19:24:30 +0000 (UTC) Received: from phl-compute-05.internal (phl-compute-05.phl.internal [10.202.2.45]) by mailfhigh.phl.internal (Postfix) with ESMTP id D9D461140259; Thu, 24 Apr 2025 15:26:48 -0400 (EDT) Received: from phl-imap-09 ([10.202.2.99]) by phl-compute-05.internal (MEProxy); Thu, 24 Apr 2025 15:26:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc: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=fm1; t=1745522808; x=1745609208; bh=JL0oiiVdxm v055bWuCFViqjBX6+DBh1u9b4WPjQ4PPg=; b=khzIewnoZfPa7BF6FwiX4r8kN5 t3PHGcpoau4uwQJ0RZ9bmUbyvW19uGUNE/dmBwl4ixF+WLEJ4D9mJAQqgKY2C8Jm 2NEbD0dBugL+JaOEV8CbgWvoWrCFQ9pz1GlzZD4UE6hBlGdivZMOI+lK2oCyyn16 xyoEQo66U8p+YOdqBVVgJWxFrRjxHnLM0zugbQEr0W1HkrFGWtSsrUywM8x/xff7 VMkBcpXKsqS1w0mYJt81RapUMzwc4UMSrc6K0U0OhRsXqU1FE469DkILzBtUQQGi Iblk5ikZqzgUbzm1zBGFtiK7DGSsijJdjNFwx4t0QGrzdA9pT3jgbgCuMGIg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=fm3; t= 1745522808; x=1745609208; bh=JL0oiiVdxmv055bWuCFViqjBX6+DBh1u9b4 WPjQ4PPg=; b=Gb1oT08HstGnVsnTl0XP5uLSa6qnQyXJpfuY4zC7PfyXKM5oOoT zKnY4KZCOTlGGv0vijFzXBFtHyRsZBFbLCWlC3+1jUxFgqxqRma1Vhtk7z7guu0l cNpUFvSsDSyEILStlCl9LoFxo+Pz4+klUrPt71MKe8D3iJk0bBsfbkN6PHyvspp7 da+maCpDBB/EGE6TddS6TeBqSMI4ujV7hYahRthcyk/VTZ5YNsUjIjOdkz7m5W9r eUyQ7uJuhYXYpKvsZ7hy67YQEBfh2KGXyHXK5gQQ++UUq/DIf8hn2m1ijvb6C5g8 Iqb8n8d85jmAPcNfYPSrlGJwnXldwI8u0rw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvhedtfedtucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucgoufhushhpvggtth ffohhmrghinhculdegledmnecujfgurhepofggfffhvffkjghfufgtsegrtderreertdej necuhfhrohhmpedftfhosgcunfgrnhguvghrshdfuceorhhosgessghothhtlhgvugdrtg houggvsheqnecuggftrfgrthhtvghrnheptdeitddvvdevhfdufffhgeelffetgeffveek heekfeeluedutdeiveekvdetjedvnecuffhomhgrihhnpeefvheglhdrohhrghenucevlh hushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrohgssegsohht thhlvggurdgtohguvghspdhnsggprhgtphhtthhopedvpdhmohguvgepshhmthhpohhuth dprhgtphhtthhopehtihhmsegsrghsthgvlhhsthhurdgsvgdprhgtphhtthhopehinhht vghrnhgrlhhssehlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 8A777780069; Thu, 24 Apr 2025 15:26:48 -0400 (EDT) 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 X-ThreadId: Te5d7a0ed2909808f Date: Thu, 24 Apr 2025 21:26:14 +0200 To: =?UTF-8?Q?Tim_D=C3=BCsterhus?= , internals@lists.php.net Message-ID: <72ef8352-2afb-4024-b4ae-857fcd94edd6@app.fastmail.com> In-Reply-To: References: <48dce917-d147-456b-9f03-c7e23411adff@app.fastmail.com> <8a16b81c-7dab-4523-a352-76ba0cb4e771@app.fastmail.com> <9c4ac301-dfb2-49da-90e5-37a2824fc4e3@app.fastmail.com> <5b1e6d70-a1c9-455c-93d3-6b22cf1fef11@app.fastmail.com> <52d84a5b-09d3-4e42-9620-a62fb239c21e@app.fastmail.com> <09a82882-f1ee-4bdb-8a27-e46144a711f1@app.fastmail.com> <706e22d7-94eb-44bd-a280-f629ba93b630@app.fastmail.com> <03a5b9a8-9fe1-4656-ab04-dd58669488b3@app.fastmail.com> <158a5d7c-8ef6-4b5f-b8ef-593879a7a896@bastelstu.be> Subject: Re: [PHP-DEV] Re: RFC: Nested Classes Content-Type: multipart/alternative; boundary=b9af46735f294349a55c33fb6123ed23 From: rob@bottled.codes ("Rob Landers") --b9af46735f294349a55c33fb6123ed23 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Thu, Apr 24, 2025, at 17:20, Tim D=C3=BCsterhus wrote: > Hi >=20 > On 4/24/25 17:09, Rob Landers wrote: > > Thank you for your feedback! I think you would then have the problem= that was pointed out by Levi the other day; where you would then have a= mbiguity. If you could have both private and public names in the same na= mespace, then you would end up not knowing which one was being referred = to. >=20 > That is a design error in the RFC then. This was very deliberate after much feedback and careful design. People = were quite clear (including yourself, if I recall) that they didn't want= a new syntax. Since there is no new syntax, there is no way to tell (fr= om the outside) whether A\B\C refers to a nested class or an outer class= . That's by design and mirrors other languages and how they handle neste= d classes. >=20 > > Also, it is worth pointing out that private symbols are *not* "invis= ible" or "non-existent" from outside classes. They emit their own errors= : https://3v4l.org/PEGeA that indicate you tried to access something you= shouldn't be able to. This is different than when you try to access som= ething that actually doesn't exist: https://3v4l.org/nWVPV >=20 > Fair enough about the error message. You can also access them with=20 > Reflection or the Closure hack. They are nevertheless =E2=80=9Dnon-exi= stent=E2=80=9D=20 > from the public API PoV: https://3v4l.org/Us6VV >=20 > =20 > class Foo { > private string $bar =3D "foo"; > private function foo(): array {} > } >=20 > class Bar extends Foo { > private array $bar =3D []; >=20 > private function foo($foo): int {} > } >=20 > class Baz extends Bar { > public self $bar; > } >=20 > $baz =3D new Baz(); > $baz->bar =3D $baz; >=20 > var_dump($baz); >=20 > In subclasses I can =E2=80=9Credefine=E2=80=9D private properties or m= ethods and they do=20 > not interact at all. Properties have separate storage locations and ca= n=20 > have differing types. Methods do not need to have compatible signature= s=20 > either. >=20 > Best regards > Tim D=C3=BCsterhus >=20 I'm not sure what you are saying here. I mean, what you are saying is se= lf-evident but I don't understand how it applies to nested classes. You = can write the following without any issues: class Foo { private class Bar {} } class Bar extends Foo { private class Bar extends Foo {} } And it will work just fine. You could even make the nested classes publi= c if you want to, or one of them private and one of them public. As ment= ioned in the RFC, the nested class is bound to the lexical scope of the = class it is written in. So Foo\Bar and Bar\Bar are different classes alt= ogether in the example above. =E2=80=94 Rob --b9af46735f294349a55c33fb6123ed23 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable


On Thu, Apr 24, 2025, at 17:20, Tim D=C3=BCsterhus wro= te:
Hi

On 4/24/25 17:09, Rob Landers wrote:
> Tha= nk you for your feedback! I think you would then have the problem that w= as pointed out by Levi the other day; where you would then have ambiguit= y. If you could have both private and public names in the same namespace= , then you would end up not knowing which one was being referred to.

That is a design error in the RFC then.

This was very deliberate after much feedback= and careful design. People were quite clear (including yourself, if I r= ecall) that they didn't want a new syntax. Since there is no new syntax,= there is no way to tell (from the outside) whether A\B\C refers to a ne= sted class or an outer class. That's by design and mirrors other languag= es and how they handle nested classes.


> Also, it = is worth pointing out that private symbols are *not* "invisible" or "non= -existent" from outside classes. They emit their own errors: https://3v4l.org/PEGeA that indicate yo= u tried to access something you shouldn't be able to. This is different = than when you try to access something that actually doesn't exist: = https://3v4l.org/nWVPV
=
Fair enough about the error message. You can also access = them with 
Reflection or the Closure hack. They are never= theless =E2=80=9Dnon-existent=E2=80=9D 
from the public A= PI PoV: https://3v4l.org/Us6VV

     }









= --b9af46735f294349a55c33fb6123ed23--