Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130825 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 514941A00BC for ; Mon, 11 May 2026 08:38:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1778488724; bh=31lnYJMLadrusCphkL/rSOCGnoU/6geh85yZP5cKArQ=; h=References:In-Reply-To:From:Date:Subject:To:From; b=JTO+LtbNhFon2NNHCeLAoZCMxaDUqVyPgIHAD61QMu2qZ+KXVolBTPIqxWtoFTCWk zt9V/aWn176fDoMjltokU5jFOtlGDnAbTJhO/LETNtr23PeqEM1Ij5FBwjr2XayNQK UGwYYzM6OMhXCOHfJzvJl0soFb8fh6gi5NxQfJ2rxrV6R+wUez2VADpqqFYBHC2xOg FZ7UYMgIe8F2ZJ2n/gF2IkDZGY2veZ2tkZym9NRZhCImRGzCxEBSpZ9A5s1lA3fa/5 jPQgyN87Smfonyqm0BC+pe9OQ/A2S7ce8Sg/6r3/6aq0tpLt5QSMa3DIEDTlvNdszp dP1O/eAMb04VA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BC519180057 for ; Mon, 11 May 2026 08:38:43 +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,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-dl1-f47.google.com (mail-dl1-f47.google.com [74.125.82.47]) (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 ; Mon, 11 May 2026 08:38:43 +0000 (UTC) Received: by mail-dl1-f47.google.com with SMTP id a92af1059eb24-12c1a170a50so5304318c88.0 for ; Mon, 11 May 2026 01:38:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1778488717; cv=none; d=google.com; s=arc-20240605; b=YKb5PUacDGyRi5bulY3eKnFA0CMPBFFb+9iRMiyVRsKQpf8V2fxOj7k244BqrURxp1 zMYuypS7WCuAlUMgcLCCWSYbTyYY40qYlddskC/Bu/CWl52voqO/7XPPCf15Ds5SDhq5 Htav62/AgK9NEsKfUHrnNaqT2SjE4QSe0yEp3/HOyeNf1z2jk4IiPNX3fQSASSl8/sB+ YQKHto1WvGq5x0QiP9D35bSI+w6v8jPIM2O7u4HwPuLrWEtHTYlwD0bL3s8Z5s1bAWfR VbG+dEoMWpO6QkPkxn5OyNh2NPNUdQZDpdXZopwfsoDlv5aBQzjYuTluJLcRu+8bCIqS ePXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=31lnYJMLadrusCphkL/rSOCGnoU/6geh85yZP5cKArQ=; fh=RnZ+4KjfdZdxwVfzmjFoBvUAaJ227RJecqE9MM9tvfQ=; b=dzXE4v5NHGk4ER8bBH/UKlDdBJDgUrcaKI5uTXJCfqp/9aLkD2o4GWghe21cq59gLP OT+MYMdFqnxR/fhwIEmOKb0gqBdkLeDRSh3q/g4fjPxFKN2qEnmJ0Anv2yzcUlDoTCYk qW0JR9zWlXY4W0a1ZKDzm4KePMRAufiIMJsNDyHzfAkdgEwsfg8MjZQY06cnq/GnYVQ6 VRDCP6FPvoRok74tulasfXfjDeyuhCJSFfxwCv86XAYDg50ykFjlh45UrVTg3HGDDZ8S wHHe7SpJ3hRZnwNFf60xYWcmEXTzYHO1EjcAHALelj8xULQGGtcobT3EmMovmZne9HLC DQ5g==; darn=lists.php.net ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jetbrains.com; s=googleapps; t=1778488717; x=1779093517; darn=lists.php.net; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=31lnYJMLadrusCphkL/rSOCGnoU/6geh85yZP5cKArQ=; b=D3eenKnxVCrldtYHTeAXEe79dhbLtrCVaxMnqjS5mdiY4zfJd6A7/LL2CZqamoVfom c4mOdOYPwdwejEBwJJmmfkVUVPSXh19/LImRKNR6sZB4282U1d6/KvL/5e/BtWlkgtSg 0wVdyTwuDbugFs81zmwadsJrbrhnoOzJJ4+Es= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778488717; x=1779093517; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=31lnYJMLadrusCphkL/rSOCGnoU/6geh85yZP5cKArQ=; b=pAqkblXRUcRdXc11OaiNcaRu6kR5UKgP8iL6T+UbaXR+a8lZx2ad57p6ao8aNntIwH UjrEOS1s4zjZ9ztAkRo+zh+/UvNy6RB8cilG0xWy4ZXTEEI4Oigo7Z1epotTEfJtczFj bOD8k40WdMGB9MR8WRQnTgbio7Bo2Y5CM276pG4FJ8xzbVikULfLN5tLREFKs+HLSsDD T65B840PVuubXWthP2FPz0qyy6idQru816QHUcGgazEUUD9ffn/wCAHpxxULiSXe/VaE PLvPiZYqkLhX6qhzjK9PmLv/P4CuYARJf9BmelEdOqnDNJbklOyeGlUrdLiYzdVq6iAm OC7w== X-Gm-Message-State: AOJu0YzjW43gF1GCYR/W+9den15wjnd4+LctdGkcrTxZ4lk/zEBsdYO5 NjyZYudGsfdDyfuSFmZrSI2xiMbZrxdP1TLs9iJJCNTFpeR3T7jLqIe/O0zov3O/gZ6TTkFMCNH u9oe+elFyNGq2fBPx7fB93EdpXHX0AkWhOr16gXzHSyOgRkcL13J+BpGO X-Gm-Gg: Acq92OF4GVYaK+E6J+icWnLRm6DKYxWBAfNIEAsIDiVYjljZGGE/rB4gcX00h5SKXHF oxVjVTPJ/fn+BoZ+5+CwbUwk3++0cw1tkVlKHa8EXYg9bkK4gRnCcvBimVLTVK5z32JKlXMpjwD soy/Dx3UlR/uXdjHekNUsuCewF/NEjoVIsfSN5NC4hAXf7Kiwg4U1CX8tV3pWzM8UODWvY4anTO nia8dYEc2Ahe6CwcHCokUW0MHdvd63VY+Qz6uNQsBjC+8VSjYXSVZ79AsL2fyxMeB2tlv1nxu8m 7fJjRVMatxk09QHzyXoV/hR4zmI1bnXr6UQm2qc= X-Received: by 2002:a05:701a:c94e:b0:12c:2dd7:9099 with SMTP id a92af1059eb24-1319d14b3e6mr9155502c88.30.1778488716983; Mon, 11 May 2026 01:38:36 -0700 (PDT) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 11 May 2026 10:38:25 +0200 X-Gm-Features: AVHnY4IyIWlSqn6-ImhmtlmW3j-yjkS6tOBqx24gzMFq6-Pz815lPg_Nn50P1bs Message-ID: Subject: Re: [PHP-DEV] [RFC] [Discussion] Bound-Erased Generic Types To: php internals Content-Type: multipart/alternative; boundary="00000000000036a383065186ac1d" From: brent.roose@jetbrains.com (Brent Roose) --00000000000036a383065186ac1d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thank you, Seifeddine, for all this work and effort; it was a very clear and even pleasant read. To internals: I'd like to highlight a couple of additional reasons why I think you should vote yes on this final RFC. 1. Although runtime-ignored generics are a paradigm shift compared to PHP's current type system, it's important to note that the target audience for this feature is already very familiar with this workflow. The value of generics (and by extension, the whole type system) for them comes from static type analysis, not the runtime type checker. Why do we need dedicated syntax then, and not stick with docblocks? Because of the reasons outlined in the RFC: a consistent spec and consistent syntax. 2. Regarding the consistent specification, you may know I work at PhpStorm, so I'd like to highlight how much of a pain the current situation is for us (and also other static analysis vendors). There is no consistency in the details. We have a huge backlog of issues regarding generic type checking that are unsolvable without a proper and consistent spec. PHPStan does X, Psalm does Y, Mago does Z; and most developers expect PhpStorm to support everything. Furthermore, performance is much more a concern for us, as we run our type checker in real time. We would love to improve our generic type support, but a proper spec is required to ensure consistency and a clear path forward. Full disclosure, we tried bringing all static analysis vendors together five or six years ago to create this consistent spec ourselves. These efforts failed, and the only viable option we see is if the spec came from internals. 3. Regarding adding new syntax that doesn't really do anything, there is precedent with attributes. Similar to generics, annotations were a docblock-only feature that got dedicated syntax, without any runtime effect besides reflection. That's exactly the mindset this RFC embraces, and attributes were very well received by the PHP community. I understand some people may fear runtime-ignored generics causing confusion, but I don't think this will be a problem, given that the target audience is: one, used to this workflow already; and, two, attributes already introduced this concept of "syntax that has no runtime effect". I hope that, along with all the arguments Seifeddine made in the RFC, you seriously consider voting yes on the final RFC, even if you yourself aren't the target audience for this feature. The vast majority of people who would benefit from generics are the people already using static analysis. Speaking with them for years both online and offline, I know most are on board with this approach. (I say "most of them", but truthfully, everyone I spoke with over the years is on board. I just avoid saying "all" because I'm sure someone somewhere disagrees). Have a good day! Brent On Sun, May 10, 2026 at 9:04=E2=80=AFPM Seifeddine Gmati wrote: > Hello Internals, > > I'd like to start the discussion on a new RFC adding bound-erased > generics types to PHP. > > Generic type parameters can be declared on classes, interfaces, > traits, functions, methods, closures, and arrow functions, with > bounds, defaults, and variance markers. Type parameters erase to their > bound at runtime; the pre-erasure form is preserved for Reflection and > consumed by static analyzers. > > - RFC: https://wiki.php.net/rfc/bound_erased_generic_types > - Implementation: https://github.com/php/php-src/pull/21969 > > Thanks, > Seifeddine. > --00000000000036a383065186ac1d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thank you, Seifeddine, for all this work and effort; it wa= s a very clear and even pleasant read. To internals: I'd like to highli= ght a couple of additional reasons why I think you should vote yes on this = final RFC.

1. Although runtime-ignored generics are a pa= radigm=C2=A0shift compared to PHP's current type system, it's impor= tant to note that the target audience for this feature is already very fami= liar with this workflow. The value of generics (and by extension, the whole= type system) for them comes from static type analysis, not the runtime typ= e checker. Why do we need dedicated syntax then, and not stick with docbloc= ks? Because of the reasons outlined in the RFC: a consistent spec and consi= stent syntax.
2. Regarding the consistent specification, you may = know I work at PhpStorm, so I'd like to highlight how much of a pain th= e current situation is for us (and also other static analysis vendors). The= re is no consistency in the details. We have a huge backlog of issues regar= ding generic type checking that are unsolvable without a proper and consist= ent spec. PHPStan does X, Psalm does Y, Mago does Z; and most developers ex= pect PhpStorm to support everything. Furthermore, performance is much more a concern for us, = as we run our type checker in real time. We would love to improve our gener= ic type support, but a proper spec is required to ensure consistency and a = clear path forward.=C2=A0Full disclosure, we tried bringing all static anal= ysis vendors together five or six years ago to create this consistent spec = ourselves. These efforts failed, and the only viable option we see is if th= e spec came from internals.=C2=A0
3. Regarding adding new syntax that doesn&= #39;t really do anything, there is precedent with attributes. Similar to ge= nerics, annotations were a docblock-only feature that got dedicated syntax,= without any runtime effect besides reflection. That's exactly the mind= set this RFC embraces, and attributes were very well received by the PHP co= mmunity. I understand some people may fear runtime-ignored generics causing= confusion, but I don't think this will be a problem, given that the ta= rget audience is: one, used to this workflow already; and, two, attributes = already introduced this concept of "syntax that has no runtime effect&= quot;.

I hope that, along with all the arguments=C2=A0Seifeddine = made in the RFC, you seriously consider voting yes on the final RFC, even i= f you yourself aren't the target audience for this feature. The vast ma= jority of people who would benefit from generics are the people already usi= ng static analysis. Speaking with them for years both online and offline, I= know most are on board with this approach. (I say "most of them"= , but truthfully, everyone I spoke with over the years is on board. I just = avoid saying "all" because I'm sure someone somewhere disagre= es).

Have a good day!

Bre= nt

On Sun, May 10, 2026 at 9:04=E2=80=AFPM Seife= ddine Gmati <azjezz@carthage.software> wrote:
Hello Internals,

I'd like to start the discussion on a new RFC adding bound-erased
generics types to PHP.

Generic type parameters can be declared on classes, interfaces,
traits, functions, methods, closures, and arrow functions, with
bounds, defaults, and variance markers. Type parameters erase to their
bound at runtime; the pre-erasure form is preserved for Reflection and
consumed by static analyzers.

- RFC: https://wiki.php.net/rfc/bound_erased_gen= eric_types
- Implementation: https://github.com/php/php-src/pull/21969=

Thanks,
Seifeddine.
--00000000000036a383065186ac1d--