Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129408 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 186F21A00BC for ; Sun, 23 Nov 2025 15:20:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1763911207; bh=iU3Wv7cts13KL+wd2d6+3EuWsEHatxluBV9lTz+6MOw=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=MPqrLzjnCc23fukoORCBpy5eHIrSDJZg+UimOpzF/dd28UlRzUsHR1eMuSiCEbpZy G67RmZCx6l0Y4LIp937vw/3o/12jPFBC5BmTLMyIxU5SujT06+LmlH3pcmlhTCXDPm SpLIqlEB2LKmeslljk4L2NvBOVbg79zoaUyqdLISE/Ptk8kVSzj6CIcdqCrsXNCwHm aEq/VHctCtlbmF0eUrk5jbFWuLITN1cQcAxqK/EeeFrF6KAuMKNhuofNBVD4/D6RtM 61WJRwGvxJlZ8W/qJkjteoJXtEEFGrMfcZULMO5LGWjGKAQJ5iCMwM1xxHRaxmmkva Mpn1T/exAfMIA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id F21DB18005B for ; Sun, 23 Nov 2025 15:20:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 23 Nov 2025 15:20:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1763911195; bh=+Hvevfk7BYHP+mcoqGi4Z1mT0ufym44PvHq2j2J1ylg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type:from:to:cc:subject:message-id; b=TOqwwdcZGvd22VSmEgZJYsrrB7+HgTvChEM2ZukKxqoXjyxWi5092pl/OBcuaUFNh Namg5VVCJ6vi9zLutYN/TnDboOICFaQ7E46qtkhgN2MTfz3v5LuxWnPbAdpCKdnVpU T4yeC9FL8w7Ou7sbNzas8HuzSXyUZiXe7QfBVpKIAIbUxn36IYUDqEzTnkm+4mjRep A5MmZc1wG1kBASmw/G/oZs0gdx5lFGc1qlJAvXYDTlYm0BsgNguUaqSPFMjZo8z4k0 SyCkspwdrx9qEAF/B3O/Zkkxh8CGkhKRJ1tya5MxKutSdB3d1z2Tpj2HX/E2iPHqpr r5m0BEGIvUW/g== Message-ID: <415c83b0-b8dc-4608-a521-826a4ede6e9f@bastelstu.be> Date: Sun, 23 Nov 2025 16:19:53 +0100 Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Subject: Re: [PHP-DEV] [RFC] [Discussion] Add values() Method to BackedEnum To: Faizan Akram Dar , Mikhail Savin Cc: Derick Rethans , Valentin Udaltsov , php internals References: <34c08e21-8cd1-2e0e-1cca-148d4acc5432@php.net> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi On 11/12/25 19:42, Faizan Akram Dar wrote: > I personally don't see any added value by adding such a method to enums at > this point when getting the equivalent results is already possible by a one > liner. > > `array_column(EnumFqcn::cases(), 'value');` I agree with that. I feel that BackedEnums are already over-used to the point where they just act as “fancy strings” instead of a proper data type on their own and I don't think we should further encourage treating enums as fancy strings. In addition to that, a custom implementation of the method is trivially done as shown by Faizan and doesn't even need to be made available by the author of the enum but can be written on demand when having all values (without the corresponding names) is necessary. And even when there is not a BC break right now, by not actually fixating the signature in the interface, it would be with PHP 9.0 and from then on it would (needlessly) block another method on enums that folks might otherwise be interested in using, since the name is very generic. Even when never adding it to the interface - static methods on interfaces are odd - it would break user expectations that some enum methods can be redefined and others can't. Best regards Tim Düsterhus