Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126816 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 B52FA1A00BC for ; Tue, 18 Mar 2025 02:37:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1742265312; bh=tXl8bhOw6RpqgtKujbAzv77J5mVzVYs5IHqg5u/4fkY=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=QI1HPmX931VL5HASBkKIEB5K9fWL8eo2hdA1FVtm1xfHXsxu9Ouk3uNbWKhH5Y7FP VTLi696GoILn1l5krAI3r4pTe+/FwA96s6ZL0zoL6ELdhFDX68+qDoh9gbZuw5+iE2 pCvp9TS4aqV9NR7lI6p53CCH7N0onQEifk6AU8LRntn4Baaj1r6O2HG2PZ98Dg9F5K M3M/MZmAp6jo13BurVkxYCMIruHd+1p6tdnQtn+b5V0SLCuD6vi1sWIK8rumFW0X6W msFqaRDwC5NzUb1Av6RszcKdfVQh9LD6bV81HFCgP8lmZnn3V8NdZNoEga8mB4Dkxy S1uzIsSQ/tK/Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id F3998180032 for ; Tue, 18 Mar 2025 02:35:11 +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=-3.6 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2012.outbound.protection.outlook.com [40.92.89.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 18 Mar 2025 02:35:11 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ysMTR92FoPZrEbuoky+7B0Ci19lqOVacM5LBCSDWnNvgNwyAaQrQ2T3S11kZEuXHuNqek+mdsTHoIIJOO26wPzocYkj6EgYpiHTN4CGSP3uEYoRLDeA6IlL7fs1t0nlzZ9cUwu5u3Pk8/nFhufayI1cKJvMPnW5FVb+mjuwjQxQVREub+TZCZ7nrf7cx7uAg7n8ryGQxLm6TSXkD2ufshmZShJBC8guBeJA0ROfOPDLfGBVdK8VPLN/iEVMCMdmGuoIiv6dIjNsE7kmqRF2r/KLZbEtFTDspgLMxegIZykQvTIfttZ+ZINA1s4Sa9UmaDhMZjmEkuHIpxtOpLhawsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hn8FblAUiFmT6+1Y6o/89lVDXkcVqmVowtwlKxHWDPU=; b=SBHKavKpUXwWYXCJV8xKqxIU/9cArShJC41Jw4cqbAxj/q6G9IRkjfuVEY7Lrwo+clQqAeV2WGGeRKiE0qya5xptsIMeEmEx9tfP+wvId8ifDJlZGEmKcwjSjp/awZJCRLMPXstXZNcSZYevmKC5u0uM/XbB6qcVjxWMKE1XW+IQsf+6TEGBlCat3nd6KYQ3B9VrRrnvEFTtYUlIJt6+Bfzn4br+8UXauZ/s5IZbwEIQL7LJjvSm+I9JVimHnPwjWYEuvW4vByHcovAIDW1ua5h2XfRxpQvnG2sP4hQCYeiDlUZq7xdGBGhzmlikYYniVH/GLIcMRVLvN4VT6HLfPQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hn8FblAUiFmT6+1Y6o/89lVDXkcVqmVowtwlKxHWDPU=; b=JWGj8Evt0cB7hYXv46LlLY0KKNT+yavD0Z4ur8mbeSL/2KUmDswd54tfh14pA3M3KgqN8OqmabkB69yEmccV+GqFF0HlyupRxwAAk8FJScp0THG0pbu36ZrRZvLDXtXz8CFTuIzgTh++SGqhXcpSJsXsrG3jNTr1zmX3aJch36RYerr30rBVV2TP20hwMUjpBmkim2VAet65HlJ0XxKc5ZyWNGlppR5jQmay79LFCdhUxPtpJ32hvMOpr17nv9tQn/kt15S/EFxjTdK/j0G+JJ4v0b6bANv0eEghhO9OS09m5qVzbt+hZO3FIc4ToI0fb6nEoP2eCHh1a5bs5OwbQQ== Received: from DU2P250MB0176.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:275::16) by DU2P250MB0222.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:277::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.33; Tue, 18 Mar 2025 02:37:36 +0000 Received: from DU2P250MB0176.EURP250.PROD.OUTLOOK.COM ([fe80::df95:81cf:3abc:1e65]) by DU2P250MB0176.EURP250.PROD.OUTLOOK.COM ([fe80::df95:81cf:3abc:1e65%5]) with mapi id 15.20.8534.031; Tue, 18 Mar 2025 02:37:36 +0000 Content-Type: multipart/alternative; boundary="------------Cpw6FbLBLalyfjJGGYQSw0Rx" Message-ID: Date: Tue, 18 Mar 2025 03:37:34 +0100 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] RFC: short and inner classes To: Rob Landers Cc: internals@lists.php.net References: <3e4ba7ea-a154-452d-abfc-05ef1322fade@app.fastmail.com> <782d76d9-711a-4cee-ae0e-fe0d69973f53@app.fastmail.com> Content-Language: en-US In-Reply-To: <782d76d9-711a-4cee-ae0e-fe0d69973f53@app.fastmail.com> X-ClientProxiedBy: FR4P281CA0260.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:e8::7) To DU2P250MB0176.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:275::16) X-Microsoft-Original-Message-ID: <7352fe17-899a-497f-ad3f-53441db12c53@hotmail.com> Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2P250MB0176:EE_|DU2P250MB0222:EE_ X-MS-Office365-Filtering-Correlation-Id: 2ace4ddd-cdc4-456a-f028-08dd65c5d77e X-Microsoft-Antispam: BCL:0;ARA:14566002|5072599009|461199028|12121999004|8060799006|19110799003|15080799006|7092599003|19061999003|440099028|3412199025|12091999003; X-Microsoft-Antispam-Message-Info: =?utf-8?B?bm8rZlcvV0V3a0VVVXkxL1dZWFhrVWt5ZmRST0xubGQyelRHcnBwQUF0Z1pS?= =?utf-8?B?VWxTVk83dmxCWDM1SHgvd2djQWhaWHlrc0VNMTNsaHRTZ21uSk96SS9HN1Nk?= =?utf-8?B?RHBidk51SXkvUktTMXpQek92UGE1SDl0eVEwTFltR2lvYVJveElaVi8wNTQ1?= =?utf-8?B?OXZFSDVDR2JmYVlEdStrMjFjNU1ObkllSDA3S0tOWGlsL0d1cno2QXRzRlFw?= =?utf-8?B?Sk51dnk5a3RLU0xzSFBRWC9LQzh2bzhJT0VmRUZCamp2amdzZ0Z6UDhWdEFW?= =?utf-8?B?MEhOc2hCRzZobU85SVlrQlVzT3FWdWpkdjBLSkROdnh6N1NMTWZ2W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WtnWjhtWjdCNmw0bkt5QTlvR29G?= =?utf-8?B?MjViMEdhek14OUl5ZGlXaWorbEh4cGx4RzdaYXIxRWlUZnZLRzJMTUF3RjNQ?= =?utf-8?B?TWFwTGRKVFlTZUFVTDlDS2pQY2dLdlp3Sks5U2hpYUFCMnhlL0F5Ri9zZGxl?= =?utf-8?B?Ums3ZjdLQzNkd3Ewczk3QjlFaFJUTG4xakhxWm1OZWJ0WVlmN1I5ckwvSHBD?= =?utf-8?B?emJ6REE3RUdjMUJ1dkVLS1dJdWg3UTVhL3ZBMGV0YjczMk50eWh4d21xTm1E?= =?utf-8?B?U3k2OVhFMENtZWVIcnhtRWp5M1lORjNhQlR0UVBLWGVoL2NYNTBFaDl2M0lp?= =?utf-8?B?ZUtvTWlMZWd5cC9zMWx3V3pkczJnaFM2ak5QTUJQdG5DeDhJYXNtRnFMaFJB?= =?utf-8?B?T3gwRVpUbTY3Q2hXOS9CTWM3OW9nSkNlTFJmMFRqSXE4UTNTYXBMUnY5Zmxm?= =?utf-8?Q?SoImLTJGXUv5xX85BY=3D?= X-OriginatorOrg: sct-15-20-7784-11-msonline-outlook-95b76.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 2ace4ddd-cdc4-456a-f028-08dd65c5d77e X-MS-Exchange-CrossTenant-AuthSource: DU2P250MB0176.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Mar 2025 02:37:36.1048 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2P250MB0222 From: bobwei9@hotmail.com (Bob Weinand) --------------Cpw6FbLBLalyfjJGGYQSw0Rx Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hey, On 17.3.2025 19:58:39, Rob Landers wrote: > On Mon, Mar 17, 2025, at 19:05, Bob Weinand wrote: >>>> . The idea that extending the parent class doesnt no inherit the >>>> child classes doesnt make sense to me. >>>> As then if you extend a parent class and call a function of that >>>> class which could rely on the existence of an inner class, I can >>>> see a lot of headaches caused by this exact scenario. >>>> As a developer, if I extend a class, I expect the entire dependance >>>> of that class to be inherited, otherwise the extending class won't >>>> work. >>> >>> I'm not sure what you mean. When you inherit a class, you do not >>> necessarily inherit everything from its superclass. You are free to >>> override it however you want. Since we are defining "types" in the >>> sense of PHP, we cannot merely inherit a "type", otherwise we would >>> cause all kinds of issues with LSP. This is specifically why >>> inheritance works the way it does in this RFC and why `static::` is >>> forbidden. >> >> I don't understand the problem here. >> >> for each nested class in parent class: >>     class_alias(substitute parent class with child class in class >> name, class name) >> >> Very simple. There's no magic needed, it can be simply class aliases. >> This will also make static, self and parent trivially work. >> > > PHP doesn't go out of its way to prevent the developer from violating > LSP -- but where it can, it does. If a type were inherited, then the > subclasses wouldn't be able to guarantee that an inner/nested class > implemented the parent inner/nested class. Or, if it did, it would > require that all subclasses using a class of the same name MUST > inherit from the parent class as well. > > This is non-trivial to implement as the parent class may or may not > have been compiled yet when we are compiling the subclass. So, we have > no idea what the parent class actually looks like until runtime. > Further, it is much simpler to reason about each class as a distinct > type vs. maybe inheriting a type from a supertype. > > Thus, if you want to inherit from the super-class's inner classes, you > can, but this RFC won't force you to do so. In my mind, this is the > biggest argument for a `\`, because the enclosing class acts more like > a namespace than a type, from the perspective of the inner class. > > If we were to embrace `\`, then it could be argued that a namespace is > technically a class in itself, (but a partial class, to borrow from C# > terminology) and every class in a namespace is essentially just a > public class in that super-class/namespace. > > Nobody has argued that perspective, but I believe it may be > interesting (and would lay a foundation for namespace private/public > class behavior/visibility). That being said, it truly does cause > issues with autoloading -- at least, PSR-4 autoloading -- and I'm not > sure whether we should solve that problem here; however, it is > something to be cognizant of, for sure. There are other types of > autoloading supported by tools, such as composer, that do not have any > issues with using `\` as a separator. Okay, I see the point with LSP. I'm not sure whether we need to preserve LSP for that specific scenario, but neither can I say that we should ignore it. (Effectively implementing LSP would mean that there's an implicit interface matching all public method signatures of the parent class, for child classes - which is doable, but possibly too much for the initial RFC.) I would however ask, should we not implement LSP compatible inner classes, to enforce that no child class may name a class the same than any non-private inner class declared by any of its parents, until we resolve this question (in possibly a future version of PHP). I do not think we should bar ourselves from allowing this in the future. However nice grand unified naming schemes may seem, I don't think it's a good idea to pursue. Clarity and explicitness shall reign supreme here. I also don't think that the proposed visibilities are applicable to namespaced classes. In particular and in practice shared internal classes are not necessarily directly organized in a way it makes sense to organize inner classes. Also visibilities like protected propagate along the inheritance chain, something which is not given with (outer) namespaced classes. The less we mix these slightly different concepts, the better. "It's similar, except in these and those cases" is the death of all consistent experiences. Thus, let's not even attempt to pretend it is. And not pretending starts with using a different symbol than a backslash. Bob --------------Cpw6FbLBLalyfjJGGYQSw0Rx Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Hey,

On 17.3.2025 19:58:39, Rob Landers wrote:
On Mon, Mar 17, 2025, at 19:05, Bob Weinand wrote:
. The idea that extending the parent class doesnt no inherit the child classes doesnt make sense to me. 
As then if you extend a parent class and call a function of that class which could rely on the existence of an inner class, I can see a lot of headaches caused by this exact scenario.
As a developer, if I extend a class, I expect the entire dependance of that class to be inherited, otherwise the extending class won't work. 

I'm not sure what you mean. When you inherit a class, you do not necessarily inherit everything from its superclass. You are free to override it however you want. Since we are defining "types" in the sense of PHP, we cannot merely inherit a "type", otherwise we would cause all kinds of issues with LSP. This is specifically why inheritance works the way it does in this RFC and why `static::` is forbidden.

I don't understand the problem here.

for each nested class in parent class:
    class_alias(substitute parent class with child class in class name, class name)

Very simple. There's no magic needed, it can be simply class aliases. This will also make static, self and parent trivially work.


PHP doesn't go out of its way to prevent the developer from violating LSP -- but where it can, it does. If a type were inherited, then the subclasses wouldn't be able to guarantee that an inner/nested class implemented the parent inner/nested class. Or, if it did, it would require that all subclasses using a class of the same name MUST inherit from the parent class as well.

This is non-trivial to implement as the parent class may or may not have been compiled yet when we are compiling the subclass. So, we have no idea what the parent class actually looks like until runtime. Further, it is much simpler to reason about each class as a distinct type vs. maybe inheriting a type from a supertype.

Thus, if you want to inherit from the super-class's inner classes, you can, but this RFC won't force you to do so. In my mind, this is the biggest argument for a `\`, because the enclosing class acts more like a namespace than a type, from the perspective of the inner class.

If we were to embrace `\`, then it could be argued that a namespace is technically a class in itself, (but a partial class, to borrow from C# terminology) and every class in a namespace is essentially just a public class in that super-class/namespace.

Nobody has argued that perspective, but I believe it may be interesting (and would lay a foundation for namespace private/public class behavior/visibility). That being said, it truly does cause issues with autoloading -- at least, PSR-4 autoloading -- and I'm not sure whether we should solve that problem here; however, it is something to be cognizant of, for sure. There are other types of autoloading supported by tools, such as composer, that do not have any issues with using `\` as a separator.

Okay, I see the point with LSP. I'm not sure whether we need to preserve LSP for that specific scenario, but neither can I say that we should ignore it.

(Effectively implementing LSP would mean that there's an implicit interface matching all public method signatures of the parent class, for child classes - which is doable, but possibly too much for the initial RFC.)

I would however ask, should we not implement LSP compatible inner classes, to enforce that no child class may name a class the same than any non-private inner class declared by any of its parents, until we resolve this question (in possibly a future version of PHP).
I do not think we should bar ourselves from allowing this in the future.

However nice grand unified naming schemes may seem, I don't think it's a good idea to pursue. Clarity and explicitness shall reign supreme here.
I also don't think that the proposed visibilities are applicable to namespaced classes. In particular and in practice shared internal classes are not necessarily directly organized in a way it makes sense to organize inner classes. Also visibilities like protected propagate along the inheritance chain, something which is not given with (outer) namespaced classes.
The less we mix these slightly different concepts, the better.

"It's similar, except in these and those cases" is the death of all consistent experiences. Thus, let's not even attempt to pretend it is.
And not pretending starts with using a different symbol than a backslash.


Bob

--------------Cpw6FbLBLalyfjJGGYQSw0Rx--