Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113038 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 83879 invoked from network); 1 Feb 2021 15:38:55 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 1 Feb 2021 15:38:55 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4BFEE180089 for ; Mon, 1 Feb 2021 07:21:55 -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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) (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 ; Mon, 1 Feb 2021 07:21:54 -0800 (PST) Received: by mail-lj1-f181.google.com with SMTP id r14so20088596ljc.2 for ; Mon, 01 Feb 2021 07:21:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=snb+BvvbUF1P2b4pW2QoeTLbwmByeOlTxX8iddOJWNc=; b=ryIvC9Pe8tMRAifMW6gR+ORKUTXTSMdVQHkxa/citkG+4OD2g6ktaTJ6GGb5Qxv6nP dARj4xN+HvYPWndOPoabBk3gRQ695Kcq7SysWktW4B1ZdjiGqCJIciA7Q2p9k7M6nsvR +xIe9ZbiqGakqvNCo3E4EKaSH27VHhz1t4uN48bYpdnkAZHe5YHB9PYEOWU6pmicDqc+ 7CoCgdXQL3Amqh5qP1I+pewfAr9uAvORKWE5zrjFKXmP4G1lbgRCRmhEF6PqcOgKHOvC xtUxIDWsPg+hqb+W12PuZeIb+1f0p61a0uLV6MsdC31xuWd6SP7I6g5T16suf23EVomR e3cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=snb+BvvbUF1P2b4pW2QoeTLbwmByeOlTxX8iddOJWNc=; b=XOc8nAdAoA+fgBDuGWLlP037gnGtKcJFFVxgQYEejDHoDmGXQlB9zO7M2tCWHFyiel VcMfX1u4ZG/KJL/GQHN1tyAGC8lbKe+67V0PzLOK+xYCLAYOzDw//9zOOVIrdjs+Cq6h qCaVFg3c5dBZhci2S7Qk2nf4cWlAVgzuMjMYdV0PDxkyGskYxVA9WYlKf2a/Qrw+TSU1 ol/UgeeEgtLRU8J17O9zTRWEJqX/te5tE2y+kbmhfPgeiucTA/NFw5k18Oxutmtx1aOX q0QqE9iwSWsP0uw7EHk2RmebwObsAaxgZtP4d4Q0ChACE5Rfxncde0IwzoAn1uZ5AUhP j+Cw== X-Gm-Message-State: AOAM533poy/TZpBuFKBZMER8zLBJLmlrrX5amvh9OVuGtU+0JYZYZA8u TUYsAOnc3Uso84V5NjsItgTzxEdVsGtOJvZD6ysvrC1PB0c= X-Google-Smtp-Source: ABdhPJwTTePZSyY8jiftB14T4CXI4VfxVf+EAaCstZzX/lfEBrda9GJaah6mNXixa+ynBfCMZRjhwGv2jzgWBtzOAOo= X-Received: by 2002:a2e:7614:: with SMTP id r20mr10952263ljc.93.1612192912277; Mon, 01 Feb 2021 07:21:52 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 1 Feb 2021 16:21:35 +0100 Message-ID: To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="000000000000d8855d05ba47e948" Subject: Re: [PHP-DEV] Re: [RFC] Enumerations, Round 2 From: nikita.ppv@gmail.com (Nikita Popov) --000000000000d8855d05ba47e948 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Feb 1, 2021 at 2:16 PM Nikita Popov wrote: > On Fri, Jan 29, 2021 at 6:18 PM Larry Garfield > wrote: > >> On Mon, Dec 28, 2020, at 2:21 PM, 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 bee= n >> > 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. >> > >> > https://wiki.php.net/rfc/enumerations >> > >> > The implementation is 98% complete; there's still a few lagging bits i= n >> > 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. >> >> And we're back again. The RFC has been updated with a steady stream of >> smaller improvements based on feedback and testing, and is now in its Fi= nal >> Form(tm) (we think). The only major change worth noting is that we rena= med >> things. :-) >> >> An enum with no scalar backing is now called a Pure Enum, made up of Pur= e >> Cases. One that does have backing values is called a Backed Enum, made = up >> of Backed Cases. That change is mainly to allow for future expansion to >> non-scalar backing static values, should the use case arise. Reflection >> was also reworked a bit to make it more logical. >> >> https://wiki.php.net/rfc/enumerations >> >> At this point, Ilija and I consider the RFC done and ready for a vote. >> Baring any major issues being brought up, we plan to start the vote in t= he >> first half of next week, probably Tuesday-ish. If you have any other bu= g >> reports or tweaks, please speak now or forever hold your patches. >> >> --Larry Garfield >> > > Two notes: > > > =E2=80=9Cenum=E2=80=9D becomes a language keyword, with the usual poten= tial for naming > conflicts with existing global constants. > > ... and class names, which is probably more relevant here. It's worth > noting that this RFC renders many existing enum libraries unusable, such = as > myclabs/php-enum, which defines an "abstract class Enum". > > > Both Pure Enums and Backed Enums implement an internal interface named > IterableEnum > > I really don't like this interface name. We have an "iterable" type in > PHP, and having an IterableEnum that is not ... iterable would be somewha= t > confusing. IIRC you previously called this UnitEnum, which is also not > great in that "unitary enum" is not particularly well-established > terminology, but I think it's still better than IterableEnum. > > Regards, > Nikita > I'm also not really happy with the ReflectionEnumPureCase vs ReflectionEnumBackedCase split in the reflection API. I think there should be some form of common base here. That could be ReflectionEnumBackedCase extends ReflectionEnumCase extends ReflectionClassConstant, or it could be ReflectionEnumUnitCase extends ReflectionClassConstant, where getBackingValue() can return null (previous design). What was the motivation for switching to two "unrelated" classes? One more thing I'm missing in the RFC and implementation both is an API for declaring enums from PHP extensions. As far as I can tell, this is currently not possible. Nikita --000000000000d8855d05ba47e948--