Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110750 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 85184 invoked from network); 27 Jun 2020 20:21:37 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 27 Jun 2020 20:21:37 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5C74B1804A8 for ; Sat, 27 Jun 2020 12:09:52 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8075 40.80.0.0/12 X-Spam-Virus: No X-Envelope-From: Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10olkn2076.outbound.protection.outlook.com [40.92.42.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 27 Jun 2020 12:09:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GLiUTjScwRmM64DHzrJdkGJSnSgTizKsv3eYdj8bmpm/QllgyNG2L6NBh1FgHVPdoZV51HSYJ80FIOSZ9dPb6SgPHcjyz2fEPzOmc0unEjqVhZeqQuGpx2FgeXLUIPgZK5/ZeuRpPqlr5/nzQGPsaezBRMeQ2woBk+gjZpeOrAF7Mf9dxoRA2lXE72q/8XaZOCOhZxyRHe6I/EDGVJhT/arZtvhlCaXd/ROHN7rOHUEdINYeRPplb/0Dz2I92TS9XHYbfxOGy1SOCts5LgPxipDlNyg9fbz0e2cgPzkTjqzmltzPKdYjk+lTw4cI3hBajqJt4wvicZLCxX3Kw1vS/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OIwQrLiw3g8Wgu7QA+S0HHD7x+rfqRU4h/6XjCdNYvU=; b=CLVNg+GAYjxgnRWeBeegu2TQdvrNn/buVTKUQ9Z6iI/66BbuHLXdJtqsYk/5o4opmzaQBA1ngw1oTq4/jz+9xUIVZtbCjdPuvizNAm7EB46o8Vnw1NvC51hiXEaiYiyn1EOfWaXmlzWXFMKArbsMVlNa0nwKj36vs9VC5N8dVaybboe3WL9XGxtZbBGX3LY5OuXWWom00Eoes6NuD0PI+atIozRIIhDBSsNNaW3cyA0JNBqlTHJ4AJRk9sYRupupLQDku0gObGvgQdEqP6mfG1voXY25V+TGWnkIkepdanHbvRqNfCMQr/PqO7lmXueCw4UZpwSdUri9YlfTgBe8LA== 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=OIwQrLiw3g8Wgu7QA+S0HHD7x+rfqRU4h/6XjCdNYvU=; b=dMKwkeYsXqUNTijiToPAjh38Ih7m8Q7zO/kV10tpPqSCdpyuTrvMNXfEiE+ph5Zm3Gr0Vv+3MyjFa7ThYGT7iCIbck4Afryekxy8IbRqaxdyF/8HVZWSutGDOSispYqKgAd2+Fa2AUyNd5PVb4HCJ91CTW/4CasLJ5r09ub7NG/ZQQfHB/GWVZ8NmjGUKQZjbJDvhqc/4B91hwU9vufIxuyYXsx8KK9O2YrML5C8YSQPbgKjYqrqI2Qtrp65mLTzB4BG184f+CA4ZP/j8v81myHIhcmngRij/oSYGr6VqNpImIbN/WoO4pyy3JHLEd1JsCywpK2LG1gSJ6EnKu2K1A== Received: from BN7NAM10FT010.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::50) by BN7NAM10HT017.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::385) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.20; Sat, 27 Jun 2020 19:09:49 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2a01:111:e400:7e8f::43) by BN7NAM10FT010.mail.protection.outlook.com (2a01:111:e400:7e8f::421) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.20 via Frontend Transport; Sat, 27 Jun 2020 19:09:49 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::f0c8:f413:c7c1:e934]) by DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::f0c8:f413:c7c1:e934%4]) with mapi id 15.20.3131.026; Sat, 27 Jun 2020 19:09:49 +0000 To: Stephen Reay , PHP Internals Thread-Topic: [PHP-DEV] Trait constants Thread-Index: AQHWTIpKLDck9mPv2EayWWFI6xKnrqjsz9ys Date: Sat, 27 Jun 2020 19:09:49 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:BDD1B9BDCA4FDF8B313DD1F92C44258BDEC616F5C00DE7D60262F9577DB599F6;UpperCasedChecksum:1B293E5C81B2E216173A5CA44117FA67B773BE26F18CD484E3D29AEEBBAC9DA9;SizeAsReceived:7013;Count:44 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [mZ4L2EHN9p+9gA2cu3dOD6thbdbQRyuPtJXQrmBZP4uh595h6FlkbB1aIqTMRZqF] x-ms-publictraffictype: Email x-incomingheadercount: 44 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: 0a117f9e-9c05-4f46-a1b0-08d81acdaa28 x-ms-traffictypediagnostic: BN7NAM10HT017: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: fo/tpLsnkSS90QQgl1ij8u/SrpJbRK8JZzxeOAX/f912q/t5dBMwDXTl4+U/f/hw88HQez9fKsv+F9LTJ4W94KmuvC+Q3fV7fGq88O+aMMU/BrgP5wYZn/tFRTYEtR7N5GrM3RZifed4cRYwarfDnIowNYW5ac7z456gOOrYBHhTxF+sY5g/MRUHMxCEUa2m7qddJX9QM9g0HsG7zOABsQoZDTrUi8UUUdU5s7Yzrhae+KztDVR4yKiuxGsTBERW x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:0;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR07MB6618.namprd07.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:;DIR:OUT;SFP:1901; x-ms-exchange-antispam-messagedata: h/cbeCve1vNrrC4LdyRa56+0zdWlnibmWyae+w0eyglRBv09EAb8SSNp04kTBvQ8KFCLZ50HhfM8+xWJ0Yink0FZOQN6gO1pGBiBrbMczOwD0Sj09kuGgdvUn5hmpSrse+N04z+GhijpZH9AD3JIAhX6C9k+GwFjEMuoxAcHGVG69luMSMPKwpieyn9fGnFQsyU3vzaTHntzizRM69+ooQ== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-AuthSource: BN7NAM10FT010.eop-nam10.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 0a117f9e-9c05-4f46-a1b0-08d81acdaa28 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Jun 2020 19:09:49.7093 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7NAM10HT017 Subject: Re: [PHP-DEV] Trait constants From: tysonandre775@hotmail.com (tyson andre) > It=92s always struck me as slightly odd that traits don=92t support const= ants the way classes and interfaces do.=0A= > I tried to find an explanation of the lack of support in the original RFC= , and came up empty.=0A= > =0A= > A consequent discussion in R11 has led me here.=0A= > Can anyone working on internals explain why traits don=92t allow constant= s (either technically or philosophically)?=0A= > Moreover, what=92s the opinion(s) of the list, on adding support for this= ? Would an RFC be needed? =0A= =0A= I'm in favor of adding it. I doubt there's any insurmountable technical obs= tacles.=0A= (I work on a static analyzer for php (https://github.com/phan/phan) and don= 't expect technical issues with that proposal)=0A= I personally find it inconvenient to put constants used by traits in differ= ent classes/interfaces or in properties.=0A= =0A= Other languages allow adding constants to traits:=0A= =0A= - Java allows defining constants on interfaces, which allow defining defaul= t method implementations like PHP traits=0A= - https://doc.rust-lang.org/edition-guide/rust-2018/trait-system/associated= -constants.html allows defining constants with values on traits=0A= (it also does various other things that impractical for php)=0A= =0A= One thing to document/add tests for would be the resolution of `self::MY_CO= NST`.=0A= In a trait, `self::method()` may be overridden by the method of the class t= hat's using the trait.=0A= I'd expect `self::MY_CONST` to be the same.=0A= =0A= ```php=0A=