Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110865 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 71910 invoked from network); 7 Jul 2020 17:34:51 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Jul 2020 17:34:51 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6CA6218050A for ; Tue, 7 Jul 2020 09:25:35 -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.5 required=5.0 tests=BAYES_05,HTML_MESSAGE, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS36024 206.123.114.0/23 X-Spam-Virus: No X-Envelope-From: Received: from mail1.25mail.st (mail1.25mail.st [206.123.115.54]) (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 ; Tue, 7 Jul 2020 09:25:34 -0700 (PDT) Received: from home.th-ayu.reay.family (unknown [49.48.223.67]) by mail1.25mail.st (Postfix) with ESMTPSA id 5EDF160668 for ; Tue, 7 Jul 2020 16:25:29 +0000 (UTC) Content-Type: multipart/alternative; boundary="Apple-Mail=_2D795DA9-5F2B-41E7-95F1-E92ADD256E77" Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Date: Tue, 7 Jul 2020 23:25:26 +0700 References: To: PHP Internals In-Reply-To: Message-ID: <63D74B9A-AC65-4B43-A078-A1A6E031E7D8@koalephant.com> X-Mailer: Apple Mail (2.3608.80.23.2.2) Subject: Re: [PHP-DEV] Trait constants From: php-lists@koalephant.com (Stephen Reay) --Apple-Mail=_2D795DA9-5F2B-41E7-95F1-E92ADD256E77 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On 28 Jun 2020, at 19:33, Nikita Popov wrote: >=20 > On Sat, Jun 27, 2020 at 3:53 PM Stephen Reay > > wrote: >=20 >> Hi, >>=20 >> It=E2=80=99s always struck me as slightly odd that traits don=E2=80=99t= support constants >> the way classes and interfaces do. >> I tried to find an explanation of the lack of support in the original = RFC, >> and came up empty. >>=20 >> A consequent discussion in R11 has led me here. >> Can anyone working on internals explain why traits don=E2=80=99t = allow constants >> (either technically or philosophically)? >> Moreover, what=E2=80=99s the opinion(s) of the list, on adding = support for this? >> Would an RFC be needed? >>=20 >=20 > Sounds like a reasonable addition. An RFC will be needed to specify = the > details, which tend to be tricky whenever traits are involved. Some > suggestions: >=20 > * Constants mustn't be accessible directly on the trait, i.e. > TraitName::FOOBAR throws. self::FOOBAR within the trait is legal in = that > "self" is remapped to the using class, as usual. > * The same constants important from multiple traits should follow the > rules of properties, i.e. require that values match. Conflict = resolution > for constants should very much *not* be supported. >=20 > Regards, > Nikita Hi All, I finally found some time to write something to get this started. I=E2=80=99= m following the advice given, and putting this on GH initially, any and = all comments/feedback/suggestions are welcome! https://github.com/stephenreay/php-rfcs/blob/master/trait-constants.md = Note: I realise it doesn=E2=80=99t lay out voting choices, target = version etc: It seems more pertinent to focus on nailing down some kind = of fixed target of what should be achieved, before detailing the = when/etc. Cheers Stephen=20= --Apple-Mail=_2D795DA9-5F2B-41E7-95F1-E92ADD256E77--