Re: [RFC] [Discussion] Bound-Erased Generic Types
| From: | Zebulan | Date: | Thu, 14 May 2026 23:54:01 +0000 |
| Subject: | Re: [RFC] [Discussion] Bound-Erased Generic Types | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-130885@lists.php.net to get a copy of this message | ||
On Thursday, May 14th, 2026 at 6:33 PM, Seifeddine Gmati <azjezz@carthage.software> wrote:
> > But at the same time this PHP script is accepted by PHPStan despite throwing
> > "Uncaught TypeError: foo(): Argument #1 ($bar) must be of type string, int given" at
> > runtime [...]
>
> That's a bug worth reporting to PHPStan. Mago catches it correctly
>
> https://mago.carthage.software/1.27.1/en/playground/#019e28c0-28e7-a525-cb82-710da883858c,
> disagreement between SA tools on specific cases is a real ecosystem
> issue (this RFC's "Why people use generics" mentions this to an
> extent), and tools improve over time. A false positive, or a false
> negative in one tool doesn't mean that "SA-checked code is a different
> language." (You will find a ton of false positives in Mago and Psalm,
> too.)
Notably, PHPStan is already working on solutions to this kind of issue: https://phpstan.org/blog/why-array-string-keys-are-not-type-safe