Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127167 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 EFF871AF7BA for ; Tue, 22 Apr 2025 17:24:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1745342525; bh=/VDy6oUdrA/g/zQ2zbXK/+csJa+gbFNoONFqwrOiTvA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=B2iQl1q5qe8NVeDxztpNL5XBJCaNQ2QjXAHufYgongfmrQG88/RwRJrDy3m2OCgde kuhqPbDfzYG0Ry5XWgrR3rqC3wBlTojNVrl0VYhP+v0cqk68dQH4tunUxrm1Bx+N4r AeIsbhihY9XRBHIp08dwgT6wEkVOVL3RCe6jHjN+YDGkIOcSsak7P8XFVnqhgXSoIJ RPRxNvOabuUWqAg9c04jJCPgSn2uw+8mHi/GXupzPgJKeRukZxw7wtkbSmZnIX/ulf snUmH0pCQFiOwT0a/Epf8hsjHivYuuSRpw42W0cHy0Com9UG200xXuyEM1PqZhW9Zj U+HRBPHcQnMow== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 001661801D9 for ; Tue, 22 Apr 2025 17:22:03 +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.7 required=5.0 tests=BAYES_05,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,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 mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (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 ; Tue, 22 Apr 2025 17:20:30 +0000 (UTC) Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-39149bccb69so2282783f8f.2 for ; Tue, 22 Apr 2025 10:22:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datadoghq.com; s=google; t=1745342568; x=1745947368; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=1sqI6bAT3p6dTrVYCV5FqtdoUUztLo0O8mQvCE9v6+s=; b=fmQIFVrx/pcE96IWEWcWTUdqHhNJ2QYitpgU+jZf7bySECQ2sAtm5UpcS2U4+XnwRV Z2ERm1zAklIxmO/vveQanhHTv8HbZUX0+snpJyufE18WstslRyqTTwNH+3hz4N5m4FDv VrDhwOa9MXwaZtnr/55cxYzMiNx52oEjvvaCE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745342568; x=1745947368; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1sqI6bAT3p6dTrVYCV5FqtdoUUztLo0O8mQvCE9v6+s=; b=ASLUIE/c3nedd9JBt6idvxieCnTXs4lMgOGSFuCtGjiRCPd4P6EsExUdA/HWEioT/Z YigAm7B70/KuARc/EKNKTmXmhvmkAxTxKFonbv+1iI5aqkt1YzvrRKgsZonM0svt1Pp3 GLESqAMU7Yk6Bbj6gHMtW01NwkeW/rursCvS+t8bbrypK9ILgOt5cZkwQ02mnNV2iRPX BkttAzfO0hKtwTznSnBwHXtVtqrPnTwkHkcsqAtZwVDJt24KgHeXReE4V35SxdmSAWVY hVOfouxEghQ0vOKbzC8QNpFnxnvCoEzxa9LbVOuc8wRZPg2inN+6/3JrgDimfz0QI/nI r0aA== X-Gm-Message-State: AOJu0YzluBR+JnbxAs4dYNdps+P+sReaLLZGbQg6+awOOwf5HesmZF63 0XWzKixfEvbqxgX2zkdZZ0HVq/ObmZI1xHPOk545V2T/kTfLcpiVRJCTrf2+Zs1RcL3iSm1Vf2E Ygisojg9k/+cobbn/x+92XxvqyVdPMDXVNLx10A== X-Gm-Gg: ASbGncvL1nfTMUJCoSVTIrOM+v2r/VveJRquccYdARA+R5Ok0xOqpquiUUqSI/ZRsaD /ynT4uU4sl5GnJ79AviotzFpt332qrzmIBoOgGZc9gnVF2sg1u0NyE9gxcyQzl9fZTeWDOW1Cwx R3Mxfpn4rvQtZ0hcShQzaOmg== X-Google-Smtp-Source: AGHT+IEN+me4yUftgSoWRQZBJT3diH3/DrTeg9ms/CpxloCqAQli44N5Oui8q+HVP5PKPchA2hhXewThcdoGDgcmzKI= X-Received: by 2002:a5d:6488:0:b0:39c:dfa:c92a with SMTP id ffacd0b85a97d-39efbacdcc9mr13180469f8f.36.1745342568160; Tue, 22 Apr 2025 10:22:48 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 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> <03a5b9a8-9fe1-4656-ab04-dd58669488b3@app.fastmail.com> In-Reply-To: <03a5b9a8-9fe1-4656-ab04-dd58669488b3@app.fastmail.com> Date: Tue, 22 Apr 2025 11:22:36 -0600 X-Gm-Features: ATxdqUEpfVN_8wQipZyCsQIlha89AKTLmG92l0TGNxCgjQUc0Fx2apfsPAyYNX4 Message-ID: Subject: Re: [PHP-DEV] Re: RFC: Nested Classes (was: short and inner classes) To: Rob Landers Cc: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: levi.morrison@datadoghq.com (Levi Morrison) On Sun, Apr 20, 2025 at 7:46=E2=80=AFAM Rob Landers wro= te: > > 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 clas= s 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\Inner= . > > - You cannot simply refer to parent:>Inner, you have to explicitly ask fo= r the parent by name: SomeParentClass\Inner. > > A draft implementation (which is more of a proof-of-concept) is available= on GitHub. > > > Hello internals, > > As it seems that discussion has mostly died down, I'd like to put this to= wards a vote starting on May 1, 2025. > > =E2=80=94 Rob I intend to vote no. Fundamentally, this proposal adds a form of "packaging" which only affects classes. There's no packaging for constants or functions, unless you put them onto a class to make them class constants and static methods. This is weird to me. I would prefer that we work out something more general. I am also worried that naming collisions are possible. Something like this: ```php namespace A { class B {} } namespace { class A { class B {} } } ``` Where `A\B` refers to two possible things. I don't like this, and to my knowledge, this type of confusion has not been possible in the past. Of course, feel free to point it out if so. Note that methods and properties of the same name are disambiguated by syntax, where here the syntax is the same.