Re: [PHP-DEV] [RFC] Typed array declarations
[email protected] (Wendell Adriel) Thu, 16 Jul 2026 15:18:29 +0100
| Newsgroups | php.internals |
|---|---|
| Message-ID | <CA+1VZ8sJw_cD+AA7wzr4gHh7B95WE5iqR8H=_p=kbav4soCosQ@mail.gmail.com> |
> > There are some problems here: > 1. You have limited K to int or string, but none of these types can be > subtyped. As a result K1<:K2 never applies. We can only have K1:=K2. > 2. You also claim that V is covariant. However, this holds true only for > read-only arrays. Write operations of an array use V in contra-variant > positions. > I am afraid that we cannot have sound covariant subtyping of an array, > unless we clearly separate the read interface from the write one. Hey Lazare, Thank you for the feedback. I'm going to analyze this and update the RFC document accordingly ASAP. *---* *Best Regards,* *Wendell Adriel.* *Software Engineer & Architect* *https://wendelladriel.com <https://wendelladriel.com>*