Hi Derick,
Il 25/05/2026 17:28, Derick Rethans ha scritto:
On Sun, 10 May 2026, Seifeddine Gmati wrote:
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
I have just read through this well-put-together RFC again. It however
does not change my opinion that I don't believe that having types
declared, but not generally enforced, is a good idea.
I have had several conversions with PHP users over the last few weeks,
and although many would like generics, they were almost exclusively
confused when it became clear these types weren't enforced.
It would create another paradigm for PHP users, different from
everywhere else where types are defined they are enforced.
I therefore do not believe this is a way forward, and await what the
result of https://thephp.foundation/blog/2025/08/05/compile-generics/ is
going to turn out to be.
FWIW, I share the same feelings.
Cheers
--
Matteo Beccati