Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119764 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 34840 invoked from network); 29 Mar 2023 09:56:08 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 29 Mar 2023 09:56:08 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 504781804DF for ; Wed, 29 Mar 2023 02:56:04 -0700 (PDT) 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,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS24940 176.9.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (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 ; Wed, 29 Mar 2023 02:56:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1680083761; bh=juukNlDZKyWOM/WtuJRxn0tqIQV/OgzuJeRTP3GEA2Q=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type:from:to:cc:subject:message-id; b=Rcxstd+Ts+LHI0UfrHTDELCcwUyJMW0DJNypuelEeOjGYzk+Hs4AzIYj/XoJFmI5+ sGLQ/igCpAhtjnAYpxxU1tPRTXR/nnuQVH3jFKoOhaT6MpQP4FRctjOnIL+Z920XBs lS+0o2Iv6hHcmttcv7SNdcwoECpaDtgR/lN+oTptbank27qoSFYsG+SS94kqXqY0Mn ZcrNt3pGI+Z3d2aHxRnV9YXRuNf2kMQhAL9P8IQH34ru+GyERWkPoDdy9OlwZmlwUI woJ/s1+UGVEUl4KFxl6Wb/uWccHRvHdgM2R57THAkcGXJHU9UzUPy5mit4ggRzAhsg Ikd4iOHgh27xg== Message-ID: <8bbe91fa-9f32-e2c6-91b9-e982d25042ed@bastelstu.be> Date: Wed, 29 Mar 2023 11:55:59 +0200 MIME-Version: 1.0 Content-Language: en-US To: internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] [IDEA] allow extending enum From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=c3=bcsterhus?=) Hi On 3/29/23 11:42, Sebastian Bergmann wrote: > Am 29.03.2023 um 11:31 schrieb Rokas Šleinius: >> I wouldn't say removing the final attribute from enums actually "breaks" any functionality. > > I am with Marco on this: removing the "finality" from enum would be a > major backward compatiblity break as it breaks a fundamental assumption > about enums. > And to give a specific example from PHP 8.3: As part of the Randomizer additions RFC (https://wiki.php.net/rfc/randomizer_additions), PHP 8.3 got its first "natively included" enum (\Random\IntervalBoundary). This enum works together with the new Randomizer::getFloat() method to specify if the given min and max value may be returned or not. The Randomizer::getFloat() method internally includes switch statement that chooses the implementation based on the IntervalBoundary value given. If a user would be able to extend the IntervalBoundary enum, the method would not be able to make sense of it. The IntervalBoundary enum completely enumerates all four possible combinations for the two possible states for each of the two boundaries (2*2 = 4). By definition there is no other valid value. Best regards Tim Düsterhus