Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127027 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 6CFB31A00BC for ; Wed, 2 Apr 2025 17:42:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1743615573; bh=7JLhqk+eLUxRLTHldrOIaB0hbjF5kFgtekiQWPxHeRI=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=P4UKINkkybx7DD2nXeZxP9M+Rak3C+AfdHB2TdR5+LDj6yBRtzdzzoizqDUaUvdJP E7/QRXcwjC6omb+MfOlscsNMZzsWdt/+tDO/QFFzZcIwra6HVpB+TTGeJwvz6DvdeJ XPhIKgQuW65PmRMamrKPWRpLZKWCHqqJ5FUqpsDiB2wZTzeDfLMn512hEUkiLjLHXL B6gwEUtCIvoEB+bw3DZtOwRsxVVVx7z+dF9sgBhmHoXi8NfP7ZlrNbYp0C8o0k4Kh8 sHohe6O95jOW6nyXiu2Keo14MD/PRF4xD0eet/F7sMLfFMf2bzIaKwzXc86+znBUAr eauNkHBeN+eMw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 747A5180053 for ; Wed, 2 Apr 2025 17:39:32 +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 fhigh-b1-smtp.messagingengine.com (fhigh-b1-smtp.messagingengine.com [202.12.124.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 ; Wed, 2 Apr 2025 17:39:32 +0000 (UTC) Received: from phl-compute-11.internal (phl-compute-11.phl.internal [10.202.2.51]) by mailfhigh.stl.internal (Postfix) with ESMTP id 511FC254017D; Wed, 2 Apr 2025 13:41:58 -0400 (EDT) Received: from phl-imap-09 ([10.202.2.99]) by phl-compute-11.internal (MEProxy); Wed, 02 Apr 2025 13:41:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc: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=1743615718; x= 1743702118; bh=GYtCjLcva8EOmA9bYgegiYL9XzPAaj95IDBpZ7e2reE=; b=w ytoiL6vncw5baQVsLTb+eF2T0QLrb0jvfIaBWPXPYD+Q861GXklNOEtCe/sreqUH 8lV+NooKJzawmHOjZONe4eURPU9RBu0x+wMK4GFdqW53VW+qENjoUzSY9fxM0OV1 Gwv1OsZOclftdbIivoN4dRcT/2fMnp2zA2GviQ4scVz2pol22xVeXP+6acImPXVi vO7PRY8NuEql6YZiXmG4dCK2mDXd/6nTan6FzYUpYxp1y32L+FwCPPZ6EyoytnLL uOJ5TSTJjQLBYLVlWW7lS2MW1v6uyINchKIWMyCdFDRnakKxzyRaXl+QRUlhrATd lrKNFFQJO0FqSvTKRuYhQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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= 1743615718; x=1743702118; bh=GYtCjLcva8EOmA9bYgegiYL9XzPAaj95IDB pZ7e2reE=; b=VnRyN3Kwz5pN6bdR23GVCuh7SE9L/1lyNx6rEyZE5YdHm6jTI+Z ZKdEXimqF+ytwlluHaoVooo0KXgZP+4qqYk0ioCKjXaUwPA9Tn9xbHKF1BbbvY5n mK4L2bPsGTtwLhKroZg9ghH+KSR7DRoe0ivxnUDTKafV+jImUgXklNZWCW4vsfdF u6ZIfIwP7n1HclWgydkOtz510BVStmbxjnHv07Mltrqs6wYKv2UmzwH4Xou4cvzg H5VfleqPvtAOZQoYGySaFNm6qljpZxdrhz6IwATAaFfBrjkEQWFQsD3vJAqfVPE0 8/h4rCOwHOBF3WtmO7ciZi7qG2aTz4Nm1Rw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddukeeivdekucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefogg ffhffvvefkjghfufgtsegrtderreertdejnecuhfhrohhmpedftfhosgcunfgrnhguvghr shdfuceorhhosgessghothhtlhgvugdrtghouggvsheqnecuggftrfgrthhtvghrnhephe eufffhjedtjedtgeduieetteetkedvhfelheejfedugffhleethfdttdefudelnecuffho mhgrihhnpegvgihtvghrnhgrlhhsrdhiohdpphhhphdrnhgvthenucevlhhushhtvghruf hiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrohgssegsohhtthhlvggurdgt ohguvghspdhnsggprhgtphhtthhopedvpdhmohguvgepshhmthhpohhuthdprhgtphhtth hopeguvghvrdelleelrdhvihgtthhorhesghhmrghilhdrtghomhdprhgtphhtthhopehi nhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id CB7E3780069; Wed, 2 Apr 2025 13:41:57 -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: Wed, 02 Apr 2025 19:41:28 +0200 To: "Viktor Khramov" Cc: internals@lists.php.net Message-ID: In-Reply-To: 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> <25b9205e-cb96-4746-91d2-11bf7fff7edb@app.fastmail.com> Subject: Re: [PHP-DEV] RFC: Nested Classes (was: short and inner classes) Content-Type: multipart/alternative; boundary=3727fbc41ec347ae8e7593d891ab0057 From: rob@bottled.codes ("Rob Landers") --3727fbc41ec347ae8e7593d891ab0057 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Wed, Apr 2, 2025, at 07:54, Viktor Khramov wrote: > Hi Rob. > The examples in this RFC only describe usage within classes as far as = I can see. > Does this finally solve the factory methods issue? https://externals.i= o/message/126452 >=20 > =D0=BF=D0=BD, 31 =D0=BC=D0=B0=D1=80. 2025=E2=80=AF=D0=B3. =D0=B2 23:38= , Rob Landers : >> __ >> 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 RF= C: >>>=20 >>> 1. More (realistic) examples, >>> 2. Since enums are basically specialized classes, they are allowed t= o 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; bu= t 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= class 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= and autoloaders will have to account for that. It will only ask for Out= er\Inner. >>>=20 >>> - You cannot simply refer to parent:>Inner, you have to explicitly a= sk for the parent by name: SomeParentClass\Inner.=20 >>>=20 >>> A draft implementation (which is more of a proof-of-concept) is avai= lable on GitHub. >>=20 >> I accidentally forgot to include the link to the RFC: https://wiki.ph= p.net/rfc/short-and-inner-classes >>=20 >> =E2=80=94 Rob Ah, good catch Viktor, I added a factory pattern as an example. =E2=80=94 Rob --3727fbc41ec347ae8e7593d891ab0057 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
On Wed, Apr 2, = 2025, at 07:54, Viktor Khramov wrote:
Hi Rob.
<= div>The examples in th= is RFC only describe usage within classes as far as I can see.
Does this finally solve the factory metho= ds issue? https://extern= als.io/message/126452

=D0=BF=D0=BD, 31 =D0=BC=D0=B0=D1=80. 2025=E2=80=AF=D0=B3. = =D0=B2 23:38, Rob Landers <rob@bottled.codes>:

On Mon, Ma= r 31, 2025, at 21:45, Rob Landers wrote:
Hello internals,

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

1. More (realistic) examples= ,
2. Since enums are basically specialized classes, they a= re allowed to be nested as well (hat tip to Reddit),
3. Us= ing backslash as the class separator,
4. Proper scoping (a= nd shadowing),
5. Nesting is allowed in interfaces and enu= ms as well as classes; but not traits,
6. (Hopefully) Clea= rer wording,
7. Nesting in traits, or nested traits, are f= uture scope,
8. Nested interfaces are future scope too.

Some benefits of using \ as a separator:
<= /div>

- 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 provid= es a more natural usage:

class Outer {
<= /div>
  class Inner {}
  public function foo= (Inner $inner) {}
}

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

use Outer\Inner as Inner;

But it al= so has some draw backs:

- The engine doesn=E2= =80=99t know that Outer\Inner is a nested class and autoloaders will hav= e to account for that. It will only ask for Outer\Inner.
<= br>
- You cannot simply refer to parent:>Inner, you have to= explicitly ask for the parent by name: SomeParentClass\Inner. 
=

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

I accidentally forgot to include the link to the RFC: https://wiki.php.net/rfc/short-and-inner-classes
=E2=80=94 Rob

A= h, good catch Viktor,

I added a factory pat= tern as an example.

=E2=80=94= Rob
--3727fbc41ec347ae8e7593d891ab0057--