Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129212 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 7B7841A00BC for ; Wed, 12 Nov 2025 19:01:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1762974098; bh=aTWcZkzgmUcbGkFBx2L91vI+ANb+9Bxi8+Fd5XhByb4=; h=Date:From:To:In-Reply-To:References:Subject:From; b=lKooX7A0I46nj4wa3+66yu2EksYnLQSvQSA2nG1J6w5c/n26/n1iiIllXfQQfvpGf lbT1eJMj29ZqChM9uI5+PTWbwo7P99VQ6jJ00mQBxUclVoq8M3jfsw99Q/3pm9lqkf /WVFDesIf+THzyXNnlKu8KEsBaou6DAUqgqw4qzIIgyqfSMjt+VeqwrEYH4VEsm8bU TrWolg2HmeVH12O7R7YfY6jzDVmMu5RZNirNzHfoyidIndqlrbwU3/LmZE3NXuEu86 PHHD8Z3ILDepBtXTXKoL/usHupglNlNi7MRPOmEUs/15+jtg5E0wajYq5sAvaK0ygJ E6v2Dvl/eZd4w== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BA7001801C7 for ; Wed, 12 Nov 2025 19:01:34 +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=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from fhigh-b4-smtp.messagingengine.com (fhigh-b4-smtp.messagingengine.com [202.12.124.155]) (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 ; Wed, 12 Nov 2025 19:01:34 +0000 (UTC) Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.stl.internal (Postfix) with ESMTP id E2FAD7A0070 for ; Wed, 12 Nov 2025 14:01:28 -0500 (EST) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-04.internal (MEProxy); Wed, 12 Nov 2025 14:01:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to; s=fm3; t=1762974088; x=1763060488; bh=uhEHcq/jvJl/8qJYzmSSr HCDIhjf5u7bPmRA7jA6HN8=; b=Up819VuRc+QkXl8VIL5teFIb+zoOf5N3mgB7o jtZ/IJ2+gleY9qn7rZjxirgdUlfePdCW6OF1iFfN6ZhkNJYog9T8RM74LBlIQbfa GeghtzCwb5wimgnZPfM9Wt7Fnci9bB9IjW/uRQCeC0zKLh75cVJkkoGRXfC9Ehu0 msrTiiwZ64QI43RA90WRhk0VSJBdBH4IFmvazZV28XDRQsFsGHBfqmn0p3yiGYNP e4VBu+cjGpwy4xQGQxxWF7tIyE0xs4k2Y6Hdn6uG6tPkBgHWON225l5Bv9fJ5F1/ N54S1iPDO3p7mfiHpJ7wl8dGwZKJT6Az6BJzShKH1RmKoVvWQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1762974088; x=1763060488; bh=u hEHcq/jvJl/8qJYzmSSrHCDIhjf5u7bPmRA7jA6HN8=; b=T+rPKEGJJg7FXRhsE wiW00MKij+r+x/AOWF0XAa459mB1vIYTlddewjOwgVNPh6GHj3si8PpVU98AlyxV h3/f71m3cTOQupEi6UKwQTPh3+rr0ADqZCnGCSOkkS5rANhU9ZcUoyFQuVSP7yAe CPmAzLX/yllS3i2eiJXY5wJI7ZohQQ/VFPkY+59f5MVzq1F4MXV+p3ZY3KrX9e1l UkqokJDiZ8mc+zhwjIv/3XM/aEe/szQSkC0ur6t2z0LycFT+Xx8NSKWRqVmtLz80 oWELhvz2SbbCYuOzWQXsChhp9w66VU+TX8xN9mKplFSGde7hDmTMzSyYmheMSuos 0BqvA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddvtdegkeeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepofggfffhvffkjghfufgtgfesthejredtredttdenucfhrhhomhepfdfnrghrrhih ucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmqe enucggtffrrghtthgvrhhnpeevfeejvdetffehiefgueeifeefudevfefffefhudeuleel kedtjeetteehveevgeenucffohhmrghinhepghhithhhuhgsrdgtohhmpdhphhhprdhnvg htnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgr rhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmpdhnsggprhgtphhtthhopedupdhmoh guvgepshhmthhpohhuthdprhgtphhtthhopehinhhtvghrnhgrlhhssehlihhsthhsrdhp hhhprdhnvght X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 0C8C2700063; Wed, 12 Nov 2025 14:01:28 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: AHqv0UHlw5MJ Date: Wed, 12 Nov 2025 13:01:06 -0600 To: "php internals" Message-ID: In-Reply-To: References: <34c08e21-8cd1-2e0e-1cca-148d4acc5432@php.net> Subject: Re: [PHP-DEV] [RFC] [Discussion] Add values() Method to BackedEnum Content-Type: text/plain Content-Transfer-Encoding: 7bit From: larry@garfieldtech.com ("Larry Garfield") On Wed, Nov 12, 2025, at 5:35 AM, Mikhail Savin wrote: > Hi, guys, thanks for feedback > > Following the discussion with Alex and Derick, I've completed a > comprehensive BC > analysis. I need community input on a key decision: whether to include > a return > type in the interface declaration. > > ## The Two Options > > **Option A: WITH return type (current PR)** > ```php > interface BackedEnum { > public static function values(): array; > } > ``` > - BC Breaks: 71-600 implementations (1.0-8.8%) > - Better type safety and IDE support > - Consistent with cases(): array > > **Option B: WITHOUT return type (alternative)** > ```php > interface BackedEnum { > public static function values(); > } > ``` > - BC Breaks: 0 (0%) > - All existing implementations compatible > - Can add `: array` in PHP 9.0 > > ## BC Analysis Data > > Total enums with values(): 6,800 > - Compatible (: array): 6,200 (91.2%) > - Missing return type: 64 (0.9%) > - Wrong return types: 7 (0.1%) > - Unaccounted: ~529 (7.8%) > > All GitHub search links: https://github.com/php/php-src/pull/20398 > > ## Question for Community > > Which approach should we take for PHP 8.6? > > **Option A:** Accept 1-9% BC break for full type safety > **Option B:** Zero BC breaks, add typing in PHP 9.0 > > I'm inclined toward Option B (zero breaks for 8.6), but want to hear community > preference before changing the implementation. > > Thoughts? > > --- > Additional context: > - Implementation change is trivial (one line) > - Native implementation returns array regardless of interface > - Alex's array_column suggestion incorporated (+3.6k usages) > - All data verifiable via GitHub searches in PR Isn't this what the #[ReturnTypeWillChange] attribute was intended for? cf: https://wiki.php.net/rfc/internal_method_return_types That seems like an option C? It's technically a BC break, but people can just drop an attribute on it to disable the return type check until 9.0. We did the same for the various internal methods, as noted in that RFC. --Larry Garfield