Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112705 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 333 invoked from network); 1 Jan 2021 19:55:49 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 1 Jan 2021 19:55:49 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9624F1804A8 for ; Fri, 1 Jan 2021 11:31:02 -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 wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (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 ; Fri, 1 Jan 2021 11:31:01 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 227A121A for ; Fri, 1 Jan 2021 14:31:01 -0500 (EST) Received: from imap26 ([10.202.2.76]) by compute4.internal (MEProxy); Fri, 01 Jan 2021 14:31:01 -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=lRKSFI wsixLCSWM9k3pu27ys0nmarjZ2HUtO7REZh2E=; b=aAFG+4qxSD+IaIF14pQShn lhM53ozJj91ufLb8wHobnXBCj5cRyzk8ZNLLXFA/5vWNtOfKqO0eBVxM8DWu2JHs A6u+I3AHQ/QU8miD22MIWX1E7tJAyaOKQJiqer15hiC1sOTAtM7/RhxATzNzRb9v KoiH/PmuGCHEj/ETUnEKjYVlHCQdwv+PSuSOOyxT24DpfRZvm7XK19HN5QqBQ0N0 Bg8k0CXLrlP3TPVLOh/II9O39OvKvDBqH25CKwdqnhQ4uLNpVEqF23IZZLUIvt7w DbTbgWp15kNIMfYRXKQpgCUUV4fzN/GPUoQ+ZPnt3Gmtsn+ZYWBHCiAT2abjONDA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvddvjedguddvjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepveehhedvveejledvvefgleevffdtjeekledvkeeg heffgfeivdejhffhledtudetnecuffhomhgrihhnpehphhhprdhnvghtnecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhiesghgrrhhf ihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 074D514200A2; Fri, 1 Jan 2021 14:31:00 -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: <631e6b07-415d-4d66-8826-cad4802ba4b3@www.fastmail.com> In-Reply-To: References: Date: Fri, 01 Jan 2021 13:30:38 -0600 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] [RFC] Enumerations, Round 2 From: larry@garfieldtech.com ("Larry Garfield") On Fri, Jan 1, 2021, at 12:08 PM, Benjamin Eberlei wrote: > On Mon, Dec 28, 2020 at 9:22 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. > > > > I think the reflection part is the weakest of this proposal, in my opinion > there should not be a ReflectionEnum and ReflectionCase. I'd agree that Reflection is the place we still have the most open questions. (The listed attribute open questions are synonyms for reflection questions, in a sense.) I disagree with removing their reflection classes entirely, though. > - ReflectionEnum extends ReflectionClass is problematic Why? The main alternative is making it its own thing entirely, which seemed redundant. > - is hasEnum just an alias for hasConstant? Assuming you mean hasCase(), no. An enum can have constants now in addition to cases. So for instance: enum Foo { case Bar; const Beep = self::Bar; } hasCase('Beep') would return false. hasConstant('Beep') returns true. > - Same for getCases() for getConstants(). As above. Not all constants are cases. That cases are constants is an implementation convenience. > - what does getConstant() or ReflectionClassConstant::getValue return for a > non scalar enum? the instance? ReflectionEnum::getConstant() would return the case instance object, whether or not it's scalar. > In my opinion you should embrace the "desugarizing" like constructor > promotion and just keep everything with the exsiting Reflection structure. Enums are more than "just" sugar on objects, though. They're built on objects, but they have limitations that objects don't have, and features objects don't have. And ideally those will expand in future RFCs. Having no difference at all between them an objects in reflection even though their functionality is different at a user level seems needlessly confusing and limiting to me. --Larry Garfield