Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127282 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 lists.php.net (Postfix) with ESMTPS id 4F4EC1A00BC for ; Sun, 4 May 2025 13:52:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1746366615; bh=q+WVIrVyvm5APHbDaYkVEPmXsrsxC2RdLQmOezPF5DY=; h=Date:Subject:To:References:From:In-Reply-To:From; b=aJdWP13MK8A/vkV4/tmFBZE6ebSsyGHpKp/2rkwUPJU0IAnWEoN1XkJlS4KApK8C4 eKY3hGw9hBeo2xiwXdqkLjtEN7ypRyWoikcspHgKod60MPMYw/KiBT/+kSZfHh4k0k eI9q5xmsB4mygcRQm150gfNJCuEwzmm5/wr7AW2YR/+R6K/M1ddqVyUQVIAhmLDxYu T22EK7NoXt2C4VE3+jAs+byn1++xxTJiWukP9oljZMu4dtW2RzxWOwLlGNDNYAwHi1 yZGwGJdC08Xnq+jPKx9k3hd+nvUIyYVDSmwSigr7vqFyWEjGGrV+4Kj289Ris9MWe1 Jm9wRh42oMP5Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 57A10180077 for ; Sun, 4 May 2025 13:50:14 +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.2 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,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 chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (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 ; Sun, 4 May 2025 13:50:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1746366746; bh=eCOCia708pJYZN4w90m3mpdzvtsrF6uXJd5gBTB6JA4=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type:from:to:cc:subject:message-id; b=idljfnmiWrZm/2IShxJSeeQ51MyW/+GMM3N4w+be/IQffXmtBnoi7JzQCPJJ3sBrY ZVuuD1PCFrdrx/bItqTj8nF9oatSQtdMn1DcskyTKu3IEff/s2t4KBYLie1MQsJIR3 rYJwgKiBtbTCDzd34vbkCriYPzY4I3c453xblIIzXsDedjcRdXG8LT4zvoHNvGnV9k YU6yMS/iszs6zVl+rw80lsZmlGivv7PMDA4260kNGO8yYQFkAqXGsXcumGRD3bmBSn GoNBRkTNqSNfAJz/u6U809FWCGJyCFrbjPTxJwbBE9YauXSHkb26WzezSvMS8JYEyv YO0Hi7ESyBrTA== Message-ID: <681845d2-ff1e-4ab8-97b2-50fecfdcb62b@bastelstu.be> Date: Sun, 4 May 2025 15:52:23 +0200 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Subject: Re: [PHP-DEV] Re: RFC: Nested Classes To: "Rowan Tommins [IMSoP]" , internals@lists.php.net References: <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> <72ef8352-2afb-4024-b4ae-857fcd94edd6@app.fastmail.com> <213a8711-adbc-42b7-bcb8-86e64cb22cf2@bastelstu.be> <5A723310-1AB6-4D4A-88CC-52EC4E81AE5C@rwec.co.uk> Content-Language: en-US In-Reply-To: <5A723310-1AB6-4D4A-88CC-52EC4E81AE5C@rwec.co.uk> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi On 4/30/25 12:51, Rowan Tommins [IMSoP] wrote: > I think you are insisting on a different definition of "private" for nested classes than exists anywhere else in the language, and one that I've not seen evidence of in any other similar language either. It seems you want members to be "hidden", such that you can't even know they exist. No, I don't think I'm using a different definition of "private" for nested classes. > More specifically, you want their *fully-qualified name* to somehow be available for reuse. That's not how private members of a class work - methods A::foo() and B::foo() have different fully-qualified names, as do properties A::$foo and B::$foo, regardless of visibility and inheritance. It's not how "namespace private", "module private", or "file private" classes would naturally work, because they all would need to be referenceable with fully-qualified names within the scope where they were visible. The difference is that for private class members there is no chance of name collisions of the "fully-qualified" name, but there is for nested classes as proposed in this RFC. There is no way for anyone except for the author of the class `A` to create a property with the fully qualified name `A::$foo`. Granted, properties could be inherited from a parent class and might thus cause collisions with a private property in a subclass. However the same collision would happen if the child class would already have a public property of the same name. Importantly, the child class could just rename its private property without any effect on any other class and also parent classes can introduce private properties without any effect on any other class. This is difference for nested classes as proposed in this RFC, since the namespace of nested classes is shared with the namespace of regular classes and the namespace of regular classes is not “closed off” for addition after the initial declaration. > It's also not a new problem: PHP doesn't enforce a file and directory layout, and libraries can and do define things "inside" each other's namespaces. When declaring a class, you have to be aware of whether a class with the same fully-qualified name has been, or will be, declared in another file. This is correct, but all these other classes that could conflict are part of the *public API* of a library. But now with private nested classes I would also be aware of the private part of a library to avoid conflicts. Best regards Tim Düsterhus