Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126982 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 6878D1A00BC for ; Mon, 31 Mar 2025 19:45:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1743450189; bh=uFyLhz7GGfWUWD2cLh+G+EUD4fYzNqI8eLdmfhEVHcY=; h=Date:From:To:In-Reply-To:References:Subject:From; b=gbavItwVC2MPXckyn9ekQsCpjayIFSk8xtdUuspWi3aRTSqv46piaXWMKUNyhddNf 96G5RNycO+mBDlWWYujyGM9UyU1o9yWodDR2SCfd0aWFTtMfq1QZvLqjKQiUUHyqW6 GIQEw3zlPic97ELHJB//ObIgWY6MOS5o4ILB6TOlJ0ZZepU3FdDl3MHYmPayzD5Y4N qN66+Qr5vP9LQ7p2ydvhwkE4/3MM+brU/wXvFB6dFaxkx+HaMihEs5E1kSIZG1YBTm Dvf/XgWclDq/PepeGuwJ4VDrCnGZZsX3/ddecSim76mgiT3G0Y/RAiGAOOVt/+GRnV 36e57mlLVanuA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2461E180088 for ; Mon, 31 Mar 2025 19:43:08 +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_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fhigh-a8-smtp.messagingengine.com (fhigh-a8-smtp.messagingengine.com [103.168.172.159]) (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 19:43:07 +0000 (UTC) Received: from phl-compute-11.internal (phl-compute-11.phl.internal [10.202.2.51]) by mailfhigh.phl.internal (Postfix) with ESMTP id 848361140156 for ; Mon, 31 Mar 2025 15:45:34 -0400 (EDT) Received: from phl-imap-09 ([10.202.2.99]) by phl-compute-11.internal (MEProxy); Mon, 31 Mar 2025 15:45:34 -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=1743450334; x=1743536734; bh=238vSae3k5 0oelvp6bBwwiMfl+3vZfKjXkzIfXm3X8w=; b=MVKOfkQFsVGkAjMG7KVJlkiW/W FOENyfdDg86yFBxgtKDdMTS8C0Caxt2ZQ6/jvyHi8XfyxvNFfY92zICj6m9OMVgw Bcka/hNJsK10IA1LlEMoeoOmtNrmsLI6oTJ5+0kimb5MS7kHrGBuI8UfDI6a+OBD aCTbqulQh9Kz5j9MetZVLJGntBvHR1y7+x1mK1yHO/Qzw38nwvkJEHL4n4363J8k GLyIGzKDIVYqSQi65mT9lkDL8ir8sngeNXc4tBEe3itv4CeT5dM/t81suDfhxLe8 xEf1dHO8d+9gUG6kjQchc+/u27N5SC4FEzjGXL0BbuUFv3S1MQ+7L/oDoM2A== 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= 1743450334; x=1743536734; bh=238vSae3k50oelvp6bBwwiMfl+3vZfKjXkz IfXm3X8w=; b=wNcZtccYZ4LP6AFX00M/ThC43cuLUCzAjvCiZzJE0Umn0ncuwwa D69cQMqDnlIyDuUCthSRP3nDNz2RPE1vnb1dW8bZLbJPnfZQEl/1LVin4wn8EGbd qV9GZrCNCy8KsC98Eg4vXFzA3AJX6QSFi9Vx+WHCQo+uCc5x3gL1zcPr6jZqsb9W lkk2aq8kDcZiOcj0fEbJlzA2lSf0MLbfCED3fwgvUMcTJFBT/eg42DM4AqzZHEmI oefwVGyJPS/EM0Livv4Pifhsmus8mEskXL168PtfoT4VaajXAZLGtPa7pSZWuGkz RkacYnUs+1aNwpTPccjpJtX6NY2HOOv8w5g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddukedtjeelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefogg ffhffvkfgjfhfutgesrgdtreerredtjeenucfhrhhomhepfdftohgsucfnrghnuggvrhhs fdcuoehrohgssegsohhtthhlvggurdgtohguvghsqeenucggtffrrghtthgvrhhnpedtue ejtdethfeulefhtdelieduteelffdtudelheffgedtieehhfelieejgfevgeenucevlhhu shhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrohgssegsohhtth hlvggurdgtohguvghspdhnsggprhgtphhtthhopedupdhmohguvgepshhmthhpohhuthdp rhgtphhtthhopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 37D58780068; Mon, 31 Mar 2025 15:45:34 -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 21:45:13 +0200 To: internals@lists.php.net Message-ID: <706e22d7-94eb-44bd-a280-f629ba93b630@app.fastmail.com> In-Reply-To: <09a82882-f1ee-4bdb-8a27-e46144a711f1@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> Subject: [PHP-DEV] RFC: Nested Classes (was: short and inner classes) Content-Type: multipart/alternative; boundary=b726ec60e90b4ca7aa7ca33787f4b5cc From: rob@bottled.codes ("Rob Landers") --b726ec60e90b4ca7aa7ca33787f4b5cc Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 no= t 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 cla= ss as =E2=80=9Cin scope.=E2=80=9D This provides a more natural usage: class Outer { class Inner {} public function foo(Inner $inner) {} } - Standard =E2=80=9Cuse=E2=80=9D statements can alias them: use Outer\Inner as Inner; But it also has some draw 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\I= nner. - You cannot simply refer to parent:>Inner, you have to explicitly ask f= or the parent by name: SomeParentClass\Inner.=20 A draft implementation (which is more of a proof-of-concept) is availabl= e on GitHub. --b726ec60e90b4ca7aa7ca33787f4b5cc Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Hello inte= rnals,

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

1. More = (realistic) examples,
2. Since enums are basically special= ized 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 i= n interfaces and enums as well as classes; but not traits,
6. (Hopefully) Clearer wording,
7. Nesting in traits, or nest= ed traits, are future scope,
8. Nested interfaces are futu= re scope too.

Some benefits of using \ as a sep= arator:

- 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 natural usage:

class = Outer {
  class Inner {}
  public = function foo(Inner $inner) {}
}

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

use Outer\Inner as Inner;

But it also has some draw backs:

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

- You cannot simply refer to parent:>Inne= r, you have to explicitly ask for the parent by name: SomeParentClass\In= ner. 

A draft implementation (which is= more of a proof-of-concept) is available on GitHub.
--b726ec60e90b4ca7aa7ca33787f4b5cc--