Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126746 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 B4BB21A00BC for ; Fri, 14 Mar 2025 00:22:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1741911608; bh=4pRdVOe7Lwui+nN/7t2KeDuWxVdzmYIItawpky14M/w=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=dlHd4iro1kYyYNJLtU+SrHpkD8Tlksxqz9s1anFlXOjtunUPhYABjeRkW5YOZ+CLs munuinkjrMutWE2kxNbyVWqG2eGWfrApDbO6PqrwKMf3zWVJ1Tw9q5r8PNtvSHhJSy id5RVgIH2+/KvsMPkGiftq2AxRZEvG6dVXdSHXC8gtqEBe04QqHLFfBs65LjspaiGd sOFUtWq3qsIdhCqwja7PxFPYpWO961ZbMLvgb2c9jSR0lZSQdh4ycPQNFnm6zoW4U2 rEMecSKIGJOzoVOBEEL+yPFdIVQS2sua3vfD5TLPpEVY4O47QP2u/Kh54DrMGeGUHy GluuzPxHM1h/A== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7A0B6180079 for ; Fri, 14 Mar 2025 00:20:07 +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_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03olkn2038.outbound.protection.outlook.com [40.92.58.38]) (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 ; Fri, 14 Mar 2025 00:20:07 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lhelH5y6ysxEXijs3rgogVJ+2QUJ9hJBJYM/r5UjMANXrV6El8qUTvmAEqG63CC3GRqP8I7lLarAMnToSe2iq3AN8K+MQeTLX8hzAhhTN4EXCr+MqP0CrdMm8HX5C5xzSIPo1ACNvolMlSxTP33tsf3T7uNKPlcszMGj+NIwu97jiNr/JdI9ztePRmwKYWf5X+h+l74cGc9FyqrKaL2kRQvTXpTex9tDFFIu8DngcHUIO/I6Xk7Fz8LJeiENbN2U6LGjJk6Qc4fBW51GEQHSwAb7xQtxo2VnDpHYg2ZcsEYPv77CEl0lbKbqoFN2viYrXHY7xQC6Q1HNRw6EkXJiKQ== 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=hxOnL1PdTKDUifn6entOS3N5lP1T0GCWCEGwUIHvwM4=; b=o3nliGqjnkslvRTungLqyc4o803xuBpAoSR0tXnyAqAU/rCQPnybemQKRehKVB1ydT7jnKKnW2xMO+M99z87kS8Et116NxiIk8Zhm2Cs6xrTgNPglCFik+J3QeC8PFX5+DU6bY5b87MQoD413vFJLRXyhbDd6XFlPIg9MBYxM8bwcVvDhz9zkL3WU7H04PGy/26nrpk9mR7vTQWevIWrg2d+5kzaJTMPmcIldZfqoRBCGd9xEqKy7Cw+dWnZseQfGRAE+jeO4obdZE94Lx7wGJKdhYwn4awgyoBB4iRKRJyWHc55447VifSReh7iq/4R4sAoK006CMZAsqjKYacRbA== 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=hxOnL1PdTKDUifn6entOS3N5lP1T0GCWCEGwUIHvwM4=; b=FY/a0vCtSsO2l0WLdigs01mL9MCilcCmyeSdhedSsIfW4ybHT/QgWVKh1XiTsxtJz7/olmVmBG96yluNlYKjW3/WyIHX2K4sa5yNzqjXp+zaqGtSCPBKqnWsCJUlbyiTLDUWMNiA6d+nDwirwmSFwf5kI/Yqe8eHVYi4VEyx8at2n5jHqqtZ4WyDVVhPGgbPARDlHoPVIYitET+wV0r5vlsoG1HXnE1UjwE0RmEaXFuYT+XbAEHCpi28Tx9KReDMJtkkFbZWv51+Tab5sTeG9tuoJM/L4E89x2krMmOmzGc/MIlyyUH+70bl0y+bU00h1AA3udtq6+R7grXAV7klkA== Received: from AM8P250MB0170.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:321::21) by DU0P250MB0793.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:3e0::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.25; Fri, 14 Mar 2025 00:22:36 +0000 Received: from AM8P250MB0170.EURP250.PROD.OUTLOOK.COM ([fe80::651e:bbd2:b18a:80ff]) by AM8P250MB0170.EURP250.PROD.OUTLOOK.COM ([fe80::651e:bbd2:b18a:80ff%3]) with mapi id 15.20.8534.027; Fri, 14 Mar 2025 00:22:36 +0000 Content-Type: multipart/alternative; boundary="------------jeP2oAbnvj1Ybzf7Jg6A0AuK" Message-ID: Date: Fri, 14 Mar 2025 01:22:35 +0100 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] Re: RFC: short and inner classes To: Rob Landers Cc: internals@lists.php.net, =?UTF-8?Q?Tim_D=C3=BCsterhus?= References: <2935d0e2-ddc4-447c-ab37-c9b7337b8b60@app.fastmail.com> <0d94bf183543ee9948fcd31337198438@bastelstu.be> <44ccdbea-747d-46ca-97f9-8dd63fe8b55a@app.fastmail.com> Content-Language: en-US In-Reply-To: <44ccdbea-747d-46ca-97f9-8dd63fe8b55a@app.fastmail.com> X-ClientProxiedBy: FR4P281CA0176.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:b7::7) To AM8P250MB0170.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:321::21) X-Microsoft-Original-Message-ID: <04f32632-1a72-480c-95e7-01d01bbab00c@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: AM8P250MB0170:EE_|DU0P250MB0793:EE_ X-MS-Office365-Filtering-Correlation-Id: 0380e9d5-7131-4ea3-726a-08dd628e5223 X-Microsoft-Antispam: BCL:0;ARA:14566002|12121999004|461199028|8060799006|7092599003|15080799006|19110799003|5072599009|8022599003|19061999003|440099028|3412199025; X-Microsoft-Antispam-Message-Info: =?utf-8?B?enlrTHEySzg4YjZ2cVBRaDBwR05jK0hFanB3Qlg3ZlNKemx5TW44cmgzTFlz?= =?utf-8?B?NGlBdUF3cUMxbmJHcEVDUy9HTzJEeDE4RlJYcStPTHpacFRyVW1xUk14aVlH?= =?utf-8?B?Qk1Lai83SGVEbWRWOXVCWmJRdy82KzNzeUJWZnB3UjczeUlxMGZaSWhzK3l2?= =?utf-8?B?L0VWdXA3MjZBYWlzZW5JMDlTazlMU3NQL2J6WkwyeGFCTk5EQmM2UUh1U0U4?= =?utf-8?B?dG54VmhCK0dzcHp1aG0xT3h3RXBHdmNRU2hEcmkvQTQzb3Q2dVFLYkxoVThj?= =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EJ3R3dGMm5ZazV4SXRPMng3RmZOeFNvVlNmV1ZrcG0rT0k5UGwrN09BS3JY?= =?utf-8?B?MUJVTmJnd3ArRTJrQ1Y5azZhZlZVdjZIMUUyclF3RkpSYnp0dnBMWnRMOXRj?= =?utf-8?B?aXZrMFNvTkZiT0N5akdmZ2R0RS9lK1QrTGd0eVd1YzNWZFdpc0hpcUNuby9v?= =?utf-8?B?VmZLWldEU2FGWGVYM0x5UFkrNkhaa0w4STdqZzZMWEtOMm5sQSsrWU9IR1lI?= =?utf-8?B?ak43dVhsd2l1M0Job21SM3NwQlNhYWZwTGUxdnJpR3NwVEg3eTQrMzJCa24z?= =?utf-8?B?S0hqQTZ5d214S0xaYnNyTENWK25EendiTzAvU1pjYXk5V1h6YjdDblNWMTdP?= =?utf-8?B?ejNJS3ZSRVNaWDNqSjJZSXI1ZjF4YVpOTmVIQ0Z6d2U2c0lDTjZWbXhFT1dQ?= =?utf-8?Q?GAFPg3rndE7kkTfKyY=3D?= X-OriginatorOrg: sct-15-20-7784-11-msonline-outlook-95b76.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 0380e9d5-7131-4ea3-726a-08dd628e5223 X-MS-Exchange-CrossTenant-AuthSource: AM8P250MB0170.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Mar 2025 00:22:36.2380 (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: DU0P250MB0793 From: bobwei9@hotmail.com (Bob Weinand) --------------jeP2oAbnvj1Ybzf7Jg6A0AuK Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hey Rob, On 14.3.2025 00:26:03, Rob Landers wrote: > My biggest issue with `::` is that it gets weird: > > class Foo { >   public class Bar {} >   public const Bar = ""; >   public static function Bar() {} > } > > echo Foo::Bar; // this is the constant > new Foo::Bar(); // this is the class > Foo::Bar(); // this is the method > new (Foo::Bar()); // this is the method > new (Foo::Bar); // this is constant > > I can now differentiate between these all in the AST, but it seems > weird to me. If we go this route, I'd personally have the preference > to allow them all and let people's code-style dictate what is > acceptable or not -- assuming I can ensure there is no ambiguity in > the grammar. At least with `:>` (or something else) we don't have to > even have that discussion. :) Why would that be weird? In 99% of the cases new followed by something followed by double colons followed by something else is just the inner class. Writing new (Foo::Bar) or new (Foo::Bar()) already today looks suspicious and will remain looking suspicious. Nothing will change about that. And "Foo::Bar" (or "Foo::Bar()") without being preceded by "new" or followed by "::" is just the normal class constant. On top of that, there are naming conventions in PHP which will make it even more obvious: class constants in uppercase and methods in camelCase and class names in PascalCase. So, just looking at Foo::Bar (without considering any surrounding tokens), you expect a class name. Looking at Foo::BAR, you expect a constant. Looking at Foo::bar you expect a method. echo Foo::BAR; // this is the constant new Foo::Bar(); // this is the class Foo::bar(); // this is the method new (Foo::bar()); // this is the method new (Foo::BAR); // this is constant // or alternatively: $myFantasticInterface = Foo::bar(); new $myFantasticInterface; $myAwesomeInterface = Foo::BAR; new $myAwesomeInterface; There's no real surprises at a glance as long as you don't intentionally make your code obscure. Bob --------------jeP2oAbnvj1Ybzf7Jg6A0AuK Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Hey Rob,

On 14.3.2025 00:26:03, Rob Landers wrote:
My biggest issue with `::` is that it gets weird:

class Foo {
  public class Bar {}
  public const Bar = "";
  public static function Bar() {}
}

echo Foo::Bar; // this is the constant
new Foo::Bar(); // this is the class
Foo::Bar(); // this is the method
new (Foo::Bar()); // this is the method
new (Foo::Bar); // this is constant

I can now differentiate between these all in the AST, but it seems weird to me. If we go this route, I'd personally have the preference to allow them all and let people's code-style dictate what is acceptable or not -- assuming I can ensure there is no ambiguity in the grammar. At least with `:>` (or something else) we don't have to even have that discussion. :)

Why would that be weird?

In 99% of the cases new followed by something followed by double colons followed by something else is just the inner class.

Writing new (Foo::Bar) or new (Foo::Bar()) already today looks suspicious and will remain looking suspicious. Nothing will change about that. And "Foo::Bar" (or "Foo::Bar()") without being preceded by "new" or followed by "::" is just the normal class constant.

On top of that, there are naming conventions in PHP which will make it even more obvious: class constants in uppercase and methods in camelCase and class names in PascalCase. So, just looking at Foo::Bar (without considering any surrounding tokens), you expect a class name. Looking at Foo::BAR, you expect a constant. Looking at Foo::bar you expect a method.


echo Foo::BAR; // this is the constant
new Foo::Bar(); // this is the class
Foo::bar(); // this is the method

new (Foo::bar()); // this is the method
new (Foo::BAR); // this is constant
// or alternatively:
$myFantasticInterface = Foo::bar();
new $myFantasticInterface;
$myAwesomeInterface = Foo::BAR;
new $myAwesomeInterface;

There's no real surprises at a glance as long as you don't intentionally make your code obscure.


Bob

--------------jeP2oAbnvj1Ybzf7Jg6A0AuK--