Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112631 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 95752 invoked from network); 29 Dec 2020 09:14:35 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 29 Dec 2020 09:14:35 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D70291804C4 for ; Tue, 29 Dec 2020 00:48:59 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from wp160.webpack.hosteurope.de (wp160.webpack.hosteurope.de [80.237.132.167]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 29 Dec 2020 00:48:59 -0800 (PST) Received: from [2a02:8109:9d40:1d44:40b6:f5d3:c567:d46c] (helo=nas.fritz.box); authenticated by wp160.webpack.hosteurope.de running ExIM with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) id 1kuAgb-00073v-LB; Tue, 29 Dec 2020 09:48:57 +0100 To: internals@lists.php.net References: Message-ID: <67c9d05a-f0a7-fcea-32ea-7a4e409308a1@mabe.berlin> Date: Tue, 29 Dec 2020 09:48:57 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US X-bounce-key: webpack.hosteurope.de;marc@mabe.berlin;1609231739;86e35e00; X-HE-SMSGID: 1kuAgb-00073v-LB Subject: Re: [PHP-DEV] [RFC] Enumerations, Round 2 From: marc@mabe.berlin (Marc) On 28.12.20 21:21, Larry Garfield wrote: > Hello, Internalians! > > After considerable discussion and effort, Ilija and I are ready to offer you round 2 on enumerations. This is in the spirit of the previous discussion, but based on that discussion a great deal has been reworked. The main change is that Enumeration Cases are now object instances of the Enumeration class rather than their own class. Most of the other changes are knock-on effects of that. > > Of particular note: > > * Cases may not have methods or constants on them. They're just dumb values. > * Enums themselves may have methods, static methods, or constants. > * Traits are supported, as long as they don't have properties. > * The value() method on scalar enums is now a property. > > The full RFC is here, and I recommend reading it again in full given how much was updated. I did and the RFC looks really awesome :+1: I don't have time to test the implementation but I noticed one thing: > If the enumeration is not a Scalar Enum, the array will be packed (indexed sequentially starting from 0). If the enumeration is a Scalar Enum, the keys will be the corresponding scalar for each enumeration. I don't think using the scalar values as keys is a good idea. What happens if we want to support scalar float values? (Why are they actually not supported in the first place?) Also I think it's more natural if both enum types return a zero-indexed-array of cases. > > https://wiki.php.net/rfc/enumerations > > The implementation is 98% complete; there's still a few lagging bits in reflection, and some opcache bugs that Ilija is still stomping on. > > There are a few outstanding questions listed that we would like feedback on. We're not entirely certain which direction to go with them, for reasons explained in the RFC. Input on those is especially welcome. > > Happy New Year. May it be enumerable. >