Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126983 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 7911C1A00BC for ; Mon, 31 Mar 2025 20:35:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1743453181; bh=49PtnI2OOyPcrTlmB4a6Wwx96ylxVMZoec7wdUYrD20=; h=Date:From:To:In-Reply-To:References:Subject:From; b=B6Vjezh+2Ji1WC6F3PuJIGwRCFV5MxMWDVKcnMkshur2XMb7X4f/H3edjWWTuzKN0 IvY3SQUSnYy4kdSMD1d/nAjeUMXBIiZCp4nzNLrXBo8VIwnvCzzOJHfJCYTtyU4z7o n22jkjRuwPnorTMYHFFJs17xtOg64jLKBw5VqPPKX2WKCAYMXGrtDEexwdt8vUzjkQ YaOQlkESFupktcdTU/IHk00iXSUAvLBxFD1LVkiycCr2D6WoCuz9RX+OhOFaEElNrf TrjKTbvfTxOI6IvWqrol9W1VgRHgRopxuWa6FZEvV8Gca++LB2ASIrmCdYv+b3UYPB K1Pwlm8eD6hXg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 426C218006F for ; Mon, 31 Mar 2025 20:33:00 +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,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fout-a6-smtp.messagingengine.com (fout-a6-smtp.messagingengine.com [103.168.172.149]) (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, 31 Mar 2025 20:33:00 +0000 (UTC) Received: from phl-compute-11.internal (phl-compute-11.phl.internal [10.202.2.51]) by mailfout.phl.internal (Postfix) with ESMTP id BDF701384352 for ; Mon, 31 Mar 2025 16:35:26 -0400 (EDT) Received: from phl-imap-09 ([10.202.2.99]) by phl-compute-11.internal (MEProxy); Mon, 31 Mar 2025 16:35:26 -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=fm3; t=1743453326; x=1743539726; bh=hzc6YGl2ne SvKHWUUsNnuE+Xox0i0VmQQ5x3jG7Vn/k=; b=h+oXVqt4imSZnOQQhpcSPd8euF 4KQRl1sER62vit4RICib6FanE/wL2XW2951I8UqiKGc446dIE9e4qlq5uo0F0X5E A9HzKR2m88WD8NZCwNN7P6NjEArDnr82TEkUiSFGotC5tSQ/9D+ldKB6YUC4scXB 1FiOlrOTUDwsflpcagPgVtzJZ/wreDoseIYqeIgGzsIIkOONX2muAYIbDN1f1oXb 8MsJrDk3b41Cp0g/lEltDu3yldvnsSShE0wiPF+WgVCCWq9UsSOGoIv8xnavghrn 5neWptugCUdWrc3StyYOooh5PNSPpgHdf9AGKvrJ5aizj2cIGth3mkEcvltA== 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=fm2; t= 1743453326; x=1743539726; bh=hzc6YGl2neSvKHWUUsNnuE+Xox0i0VmQQ5x 3jG7Vn/k=; b=qhWgOrCHwKaXMKFhLty7cgctwDKrMVrjLWpX/vIO5Fn1BTBaxm+ s/RGnt59DeHzptZ99ANpVVbWdYq+VX/ZBMYL1IqF5hromlnJxpPTQoZRFb8AVJWZ JT/Fc3sjRF6OwTWS+skrthc3WOQiupGhUhinN2hr0tfs9LCsYwdJZnaLZTqafw3Z At3YO4fNxyhy56RfKr2l5ucfXvUhpvt57rj5rfqlcxlctLcbVDe/v4B8x/r19Y4y 4mynnQdDgKiLLXqfPtdY5Xaa7fnGF8Tczv1Rk7esIicuMISrpg0J4ldJvprsSsRA 6PIr6ZAp67tH6ukjeo4tiLBY1NNvemo7YIQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddukedtkeelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefogg ffhffvkfgjfhfutgesrgdtreerredtjeenucfhrhhomhepfdftohgsucfnrghnuggvrhhs fdcuoehrohgssegsohhtthhlvggurdgtohguvghsqeenucggtffrrghtthgvrhhnpeelke ehtdfgfefhleeilefggeeihfekvdelfeejtdfflefhheehfffgudetuddutdenucffohhm rghinhepphhhphdrnhgvthenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpehrohgssegsohhtthhlvggurdgtohguvghspdhnsggprhgtphhtthho pedupdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehinhhtvghrnhgrlhhssehlih hsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 5B0B0780068; Mon, 31 Mar 2025 16:35:26 -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: T7acb3853146d671b Date: Mon, 31 Mar 2025 22:35:04 +0200 To: internals@lists.php.net Message-ID: <25b9205e-cb96-4746-91d2-11bf7fff7edb@app.fastmail.com> In-Reply-To: <706e22d7-94eb-44bd-a280-f629ba93b630@app.fastmail.com> References: <3e4ba7ea-a154-452d-abfc-05ef1322fade@app.fastmail.com> <782d76d9-711a-4cee-ae0e-fe0d69973f53@app.fastmail.com> <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> Subject: Re: [PHP-DEV] RFC: Nested Classes (was: short and inner classes) Content-Type: multipart/alternative; boundary=8961465fb3014efe8b24239569377e0b From: rob@bottled.codes ("Rob Landers") --8961465fb3014efe8b24239569377e0b Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Mon, Mar 31, 2025, at 21:45, Rob Landers wrote: > Hello internals, >=20 > I have significantly revamped the RFC (again). Key changes to the RFC: >=20 > 1. More (realistic) examples, > 2. Since enums are basically specialized classes, they are allowed to = be nested as well (hat tip to Reddit), > 3. Using backslash as the class separator, > 4. Proper scoping (and shadowing), > 5. Nesting is allowed in interfaces and enums as well as classes; but = not traits, > 6. (Hopefully) Clearer wording, > 7. Nesting in traits, or nested traits, are future scope, > 8. Nested interfaces are future scope too. >=20 > Some benefits of using \ as a separator: >=20 > - a simple name can refer to nested classes: >=20 > Scope resolution was expanded to treat inner classes within the same c= lass as =E2=80=9Cin scope.=E2=80=9D This provides a more natural usage: >=20 > class Outer { > class Inner {} > public function foo(Inner $inner) {} > } >=20 > - Standard =E2=80=9Cuse=E2=80=9D statements can alias them: >=20 > use Outer\Inner as Inner; >=20 > But it also has some draw backs: >=20 > - The engine doesn=E2=80=99t know that Outer\Inner is a nested class a= nd autoloaders will have to account for that. It will only ask for Outer= \Inner. >=20 > - You cannot simply refer to parent:>Inner, you have to explicitly ask= for the parent by name: SomeParentClass\Inner.=20 >=20 > A draft implementation (which is more of a proof-of-concept) is availa= ble on GitHub. I accidentally forgot to include the link to the RFC: https://wiki.php.n= et/rfc/short-and-inner-classes =E2=80=94 Rob --8961465fb3014efe8b24239569377e0b Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
On Mon, Mar = 31, 2025, at 21:45, Rob Landers wrote:
Hello internals,

I have significantly revamped the RFC (again). Key changes to the RFC:=

1. More (realistic) examples,
2. Since enums are basically specialized classes, they are allowed to = be nested as well (hat tip to Reddit),
3. Using backslash = as the class separator,
4. Proper scoping (and shadowing),=
5. Nesting is allowed in interfaces and enums as well as = classes; but not traits,
6. (Hopefully) Clearer wording,
7. Nesting in traits, or nested traits, are future scope,
8. Nested interfaces are future scope too.
Some benefits of using \ as a separator:

=
- a simple name can refer to nested classes:
Scope resolution was expanded to treat inner classes within= the same class as =E2=80=9Cin scope.=E2=80=9D This provides a more natu= ral usage:

class Outer {
&nbs= p; class Inner {}
  public function foo(Inner $inner)= {}
}

- Standard =E2=80=9Cuse= =E2=80=9D statements can alias them:

use Ou= ter\Inner as Inner;

But it also has some dr= aw backs:

- The engine doesn=E2=80=99t know= that Outer\Inner is a nested class and autoloaders will have to account= for that. It will only ask for Outer\Inner.

- You cannot simply refer to parent:>Inner, you have to explicitly = ask for the parent by name: SomeParentClass\Inner. 
<= br>
A draft implementation (which is more of a proof-of-concep= t) is available on GitHub.

I a= ccidentally forgot to include the link to the RFC: https://wiki.php.net/rfc/sh= ort-and-inner-classes

=E2=80=94 Rob
--8961465fb3014efe8b24239569377e0b--