Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129211 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 360A31A00BC for ; Wed, 12 Nov 2025 18:42:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1762972950; bh=4m2olo8In42r1hLANRSAYCLs+Tvq1lf6nXHFQBa+Djk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=mWOfBpL/rSAUoK1Q28xMXtV+eEm+u4TbSkGTC5N8Kgv2x6UPFpL792UC/GxIAHhrN NBMzINeHI3JD8+Uw60itIijGzAV/c+tS/S3vA/3NfrJHqAVokm7iAIkGiK+1+ShfOR HZwfL6ol2wnN8AJGCEVHGum3SLpZizzX0cNopDjRwYrQa9pRe0IzUyyfiV/nqoU2OR HBfykgDtY44dOxT77hyIuWmrL7OjAghtMGCduRnRcOxD8i5ll4Rf2QcIoSRliVx4KO /YO2rBa50e/ehLnDKDowMpRFabGsYxMypj2W9ysOS8K42JGjXHaiSboyT4+hP4USn2 olx8xEGS9LfxQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id EB2EF180086 for ; Wed, 12 Nov 2025 18:42:26 +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=1.0 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_50, DKIM_INVALID,DKIM_SIGNED,DMARC_MISSING,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SPF_TEMPERROR autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from sender4-of-o54.zoho.com (sender4-of-o54.zoho.com [136.143.188.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 12 Nov 2025 18:42:26 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1762972939; cv=none; d=zohomail.com; s=zohoarc; b=itteb60BRzMyoWVNH+6GuX2TdI1TvP+ebpZqN9jEL36YOEWEr/b4+hnhPMpJBLrlmXZmsIeMdNy+VswPu6OF3qe2tj9ZqnN2bwcZg3cQBu5opdykngWfKcwmkEbFiHKzBd38b8Gtg7BdCa6MUvdfh+YWp0txxKQBHCf9ztXwrVU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762972939; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=B5NVzN5ryqjePUTikOCfl59m330epHJ7qFhFR4etT6k=; b=D9+M6H4WhIAdO09NzXnw6t5vsYXQNeZnWExAnsZEdtyFWcaoMnnOdM2FhzlvYwwV3G+uP5J+cdf1bXhZcMYuGF0OxyffS2bnVk1+p5E4w/MiksEcqC52WYJUYAveh1JACKKyyyyf+7LCEx7r2GLpUwDCbKd+aEsoWAOTa2+XSLQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=faizanakram.me; spf=pass smtp.mailfrom=hello@faizanakram.me; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1762972939; s=zoho; d=faizanakram.me; i=hello@faizanakram.me; h=MIME-Version:References:In-Reply-To:From:From:Date:Date:Message-ID:Subject:Subject:To:To:Cc:Cc:Content-Type:Message-Id:Reply-To; bh=B5NVzN5ryqjePUTikOCfl59m330epHJ7qFhFR4etT6k=; b=T+no+dZjw8IomciFF0ppf3kTNC0H3lJMI4AuwLzanReOtgGg4+wJRBO+FxuJg02z zzaoMmcs1S75BV2jfe6ZjNZEuf/UF9Dery7rPrIg+K/S3NrRgFd6svdBsaxQhk1LunP GxhYJmxTgHIzeMtGbt3R7iXdSs/3SR3n21PJbrIs= Received: by mx.zohomail.com with SMTPS id 1762972935172922.240643435401; Wed, 12 Nov 2025 10:42:15 -0800 (PST) Received: by mail-yx1-f51.google.com with SMTP id 956f58d0204a3-640e065991dso1664753d50.3 for ; Wed, 12 Nov 2025 10:42:15 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVe/WBkrbjizKZ61jDVJqtx5M5DBXPSjTAb2+W4D2vRRTqH3dBx+8/Zz3t4biMcKna5irqgIinE/Hw=@lists.php.net X-Gm-Message-State: AOJu0YzaO2GxycujOOYwrWbTJrzKTNPiPxZk2RJkGnfcP1JNill9Yipn OLxjnzHosLNc/mlxgcCjISrod0qJuB8hY7BsnAxsEHRD3km+oWcHJW0ZYKBRWM+pk9V3EfdAii4 fhTKSdGLPC1rF2sQzoruoUxPDDkytnCg= X-Google-Smtp-Source: AGHT+IFX048mddHONML+GRP0eB0ngeMr0uDbTuqpP8YStvlPjUVhNVDqpETCcXy5NjssBkVTi1CUovas0hS8pWGym2k= X-Received: by 2002:a05:690e:d4a:b0:63f:b9fc:c65d with SMTP id 956f58d0204a3-64101a34891mr3791945d50.12.1762972934655; Wed, 12 Nov 2025 10:42:14 -0800 (PST) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: <34c08e21-8cd1-2e0e-1cca-148d4acc5432@php.net> In-Reply-To: Date: Wed, 12 Nov 2025 19:42:04 +0100 X-Gmail-Original-Message-ID: X-Gm-Features: AWmQ_bn1tZ2DG4tykpfAZJTATZPvpvQtMsFhMQqUIqwI-RutpAfMMDmj9LPx7hg Message-ID: Subject: Re: [PHP-DEV] [RFC] [Discussion] Add values() Method to BackedEnum To: Mikhail Savin Cc: Derick Rethans , Valentin Udaltsov , php internals Content-Type: multipart/alternative; boundary="00000000000084d37f06436a1ff9" X-ZohoMailClient: External From: hello@faizanakram.me (Faizan Akram Dar) --00000000000084d37f06436a1ff9 Content-Type: text/plain; charset="UTF-8" On Wed, 12 Nov 2025, 19:30 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 > > > Best regards, Mikhail > > Hi Mikhail, 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');` Kind regards, Faizan --00000000000084d37f06436a1ff9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


<= tbody style=3D"margin:0px;padding:0px;border:0px;outline:0px;font-weight:in= herit;font-style:inherit;font-family:inherit;vertical-align:baseline">On Wed, 12 Nov 2025, 19:30 Mikhail Savin= , <mikhail.d.savin@gmail.com> 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
ty= pe in the interface declaration.

## The Two Options

**Option = A: WITH return type (current PR)**
```php
interface BackedEnum {
= =C2=A0 =C2=A0 public static function values(): array;
}
```
- BC B= reaks: 71-600 implementations (1.0-8.8%)
- Better type safety and IDE su= pport
- Consistent with cases(): array

**Option B: WITHOUT return= type (alternative)**
```php
interface BackedEnum {
=C2=A0 =C2=A0 = public static function values();
}
```
- BC Breaks: 0 (0%)
- Al= l existing implementations compatible
- Can add `: array` in PHP 9.0
=
## BC Analysis Data

Total enums with values(): 6,800
- Compat= ible (: array): 6,200 (91.2%)
- Missing return type: 64 (0.9%)
- Wron= g return types: 7 (0.1%)
- Unaccounted: ~529 (7.8%)

All GitHub se= arch links: https://github.com/php/ph= p-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 hea= r community
preference before changing the implementation.

Thoug= hts?

---
Additional context:
- Implementation change is trivia= l (one line)
- Native implementation returns array regardless of interfa= ce
- Alex's array_column suggestion incorporated (+3.6k usages)
<= div>- All data verifiable via GitHub searches in PR=C2=A0


= Best regards, Mikhail



Hi Mikhai= l,

I personally don'= t see any added value by adding such a method to enums at this point when g= etting the equivalent results is already possible by a one liner.=C2=A0

`array_column(EnumFqcn::cas= es(), 'value');`



Kind regards,
Faizan
--00000000000084d37f06436a1ff9--