Re: [RFC] [Discussion] Bound-Erased Generic Types

From: Date: Fri, 15 May 2026 13:35:49 +0000
Subject: Re: [RFC] [Discussion] Bound-Erased Generic Types
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-130889@lists.php.net to get a copy of this message
On Fri, May 15, 2026 at 6:11 AM Daniil Gentili <daniil.gentili@gmail.com> wrote: >> >> >> If one would actually use the highest possible level of the static >> analysis tools they would need to “convince” the static analyzer that >> “yes, unserialize() is actually returning an object of the right type”. >> This is typically done with assert($foo instanceof >> SomeClass);, >> >> >> something that PHP will double-check for you at runtime. > > > > Interesting that you mention specifically assert, which PHP actually does **not** double-check > for you at runtime, in production by default, so there is actually a precedent for a language > feature that only does typechecking in the development stage. Assertions have been on by default for a long time, and in 8.0 we elevated them to throw instead of warn. So by default, yes, in production you do get assertions.

« previous php.internals (#130889) next »