Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113041 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 95243 invoked from network); 1 Feb 2021 18:05:28 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 1 Feb 2021 18:05:28 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A0BAD1804CF for ; Mon, 1 Feb 2021 09:48:29 -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=-0.2 required=5.0 tests=BAYES_40,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-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (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 09:48:29 -0800 (PST) Received: by mail-ed1-f52.google.com with SMTP id d2so19907747edz.3 for ; Mon, 01 Feb 2021 09:48:29 -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=t7Ndo+rXCg+6yCOpNK5GTtCU7QX167hK8QpLO7EcOLI=; b=OgTO6VroH1TErXc92Ecf+VaAD2qEUtVMuVmioQVF9baif7rKOE+Ij5g7xM3eBvXULd ZAxGnO6xBvqEMB8OmaH3fPVpXaEdQ+oIbtiWhp6YQY4dcTOTloJaE1R5L3Z8QM+5UVw3 MPQSeD94xGDJMUGj4JQMLl2sMSj8aexmd3eViK7vfQl7DSTZ281CL3UZpFtIN2XlB6a4 Dtn7EFPFXZUjhwhG2ZR0SN5k0GcrIQCRWn3NNBScZ5sdmdVOx8JL9jLRaOycYyXAVAcR SXlbQqfiEASPeqKeqZP3d+gBFPx/9gi2zV9vy5RSwaZK0wB9Iw2hEyqXWIWA7obfcxBP KQmA== 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=t7Ndo+rXCg+6yCOpNK5GTtCU7QX167hK8QpLO7EcOLI=; b=p9tbYPCIj5ma6uJLrUL2JJYZEVvTW/Ye1+HtyfbXYn6kchenglcxGWAGIqM+jxtPgk Z1WfQ8OnE+LPDZufNVtIgZ8/B+pcVKbasR/YwloeYucCL6SremI8S8YHLatxlLyG3MHu RO475cvXkK36c58ch0bBtKvRdKlcpuDYFg+EcT9R9gMl3IJABqXduYtxYup45nQfv6uT MeV3JLR+Ometl5+XwM8Bs0Fq7phXrCFML8/jKKEz9y2U6nHnDePKAUmOHBzrPkqymvZ5 +YJiYOn+SnKFsNQp6RaA0k6rPjhJEfUkQJgn9I8fjSnk791uy04zgBO8AmCARV5cpCat ob1Q== X-Gm-Message-State: AOAM531ixJFCWROMobPtLYCMSmUyOS3LFufxzWPMypfZURIgoahx2/Ym 84fvJfOMW86YKkdMhO/erHu0KJDdl2uuAQtQkRWcL4v8lRgy6ALh X-Google-Smtp-Source: ABdhPJy7SOmQHcn8i4ss2OoN7r5vOTxwbSjmUdLIi7ZzG7MSbmoOlNGVH5IxpX/51Ec+KvGFVi1ULA+Wt/A7A1ZR5II= X-Received: by 2002:a05:6402:513:: with SMTP id m19mr20193251edv.229.1612201706461; Mon, 01 Feb 2021 09:48:26 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 1 Feb 2021 19:48:09 +0200 Message-ID: To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="0000000000000520f805ba49f6fd" Subject: Re: [PHP-DEV] Re: [RFC] Enumerations, Round 2 From: drealecs@gmail.com (=?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?=) --0000000000000520f805ba49f6fd Content-Type: text/plain; charset="UTF-8" On Fri, Jan 29, 2021 at 7:17 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 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. > > > > 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. > > 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 Final > Form(tm) (we think). The only major change worth noting is that we renamed > things. :-) > > An enum with no scalar backing is now called a Pure Enum, made up of Pure > 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 the > first half of next week, probably Tuesday-ish. If you have any other bug > reports or tweaks, please speak now or forever hold your patches. > > --Larry Garfield > > Hi, Maybe IterableEnum can actually be just Enum. As you are not allowed to implement it and/or define it, wouldn't it work? That's how it's named internally in Java, not that it would matter but sometimes people forget it's just syntactic sugar there as well ( https://docs.oracle.com/javase/8/docs/api/java/lang/Enum.html): public abstract class Enum> implements Comparable, Serializable. Also in the interface I think you can include the name property, similarly with how you did in BackedEnum interface. https://wiki.php.net/rfc/property_accessors will probably allow it to be clearly defined at some point. A bit it bothers me that backed enums are very easy to implement even without the special case and just a simple Enum would be fine. I mean even if you will have a backed enum, with would be simple and probably the need will come at some point to have also a public function getLegacyValue(): string and a public static function fromLegacyValue(string $value): Enum. But yes, using backed values is a common pattern so I'm guessing it's a valuable important use case. For storing in a database purpose, property name can be used directly, I think. It would nice to have in the rfc the recommended way to retrieve the Enum, given that you know the name. I'm guessing that would be Suit::$name; Thanks, Alex --0000000000000520f805ba49f6fd--