Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112742 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 46738 invoked from network); 4 Jan 2021 03:50:01 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 4 Jan 2021 03:50:01 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0FF001804D4 for ; Sun, 3 Jan 2021 19:25:53 -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,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) (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 ; Sun, 3 Jan 2021 19:25:52 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 2CA655C0113 for ; Sun, 3 Jan 2021 22:25:52 -0500 (EST) Received: from imap26 ([10.202.2.76]) by compute4.internal (MEProxy); Sun, 03 Jan 2021 22:25:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=yxO4Hf EgOc83TM9qJoMqLeq3GgZiVKSdyKe0zm6ITd4=; b=JVTulcEzyMFt1jKXhMtW6S JSafQwqq5Z6lHKbZJZBuTzI8DR7ot1m8NAPhw1KvbDSs6l5UHwABhjxBm5s+Gfp+ ckxq29J2dCTMnB2gvzcUgxjc0u0ODNUeGQTajsOevWO+m2M4v/RKIKGgwwniwDwd a8K06p8DtYkK1Ue4y58IOP5O6+ebvT8sC0z/V7gfUrJCHoogmg0n2pZvRlX26wUs BG2ulECa9w8yaroB7F8EgPvfVMfEDOfhBKAPQTEN36SE05qlgxZyZ3/teZ+Pz7Fg rAa6TpruAU/x3bDYLsAjC0GIYRO4Sygq1cUYOIFgmlP3KmB5GGQptOszcxUSD2mQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvdefvddgheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdfnrghr rhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hmqeenucggtffrrghtthgvrhhnpeeglefgkeduiedvvdetffeujefftdfhjeeiveehgfff keduveektddvledvvdfffeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 9F2E314200A2; Sun, 3 Jan 2021 22:25:51 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.3.1-61-gb52c239-fm-20201210.001-gb52c2396 Mime-Version: 1.0 Message-ID: <76f65313-5f72-43ff-b2ee-84e91acb37dd@www.fastmail.com> In-Reply-To: <964326f1-a3ba-e343-86a6-ea88c33d45c8@mabe.berlin> References: <67c9d05a-f0a7-fcea-32ea-7a4e409308a1@mabe.berlin> <5120eee2-56c4-4608-9e41-4dd05563fef7@www.fastmail.com> <964326f1-a3ba-e343-86a6-ea88c33d45c8@mabe.berlin> Date: Sun, 03 Jan 2021 21:25:31 -0600 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] [RFC] Enumerations, Round 2 From: larry@garfieldtech.com ("Larry Garfield") On Sun, Jan 3, 2021, at 2:25 PM, Marc wrote: > >> You already provide a lookup mechanism with `MyEnum::from()` - I don't > >> see a real use-case for proving a pre build map. The main use case I see > >> is to list all possible enum values but this doesn't require a map and a > >> zero-indexed-array would also be more performant with packed arrays > >> (correct me if I'm wrong). > > I do somewhat agree with you there. We're essentially returning > > `Array|Map` which feels > > inconsistent. When you're calling cases() you're most likely going to > > loop over it at which point $case->value is available at your > > disposal. > > Would you consider making `cases()` returning a simple list in all cases > instead of differentiate between UnitEnum and ScalarEnum given the fact > that mostly people just want to loop over cases and a lookup is already > available with ScalarEnum::from() to provide a cleaner interface? > > Marc Ilija and I talked this one over a bit more, and decided that you're right. Between ->value and from() we couldn't come up with a use case that would need the assoc array that wouldn't work just as well with ->value, and it makes the method type definition simpler. I've updated the RFC to have cases() always return a packed array; Ilija will update the PR soon. Thanks for your feedback! --Larry Garfield