PHP Generics Already Exist: They're Just Hidden in PHPDoc (opens in new tab)
Every Laravel dev has written PHP generics. You just wrote them inside a comment and pretended it didn't count. /** @return Collection */ That line is a generic type. PHPStan reads it, your IDE reads it, but PHP itself shrugs and ignores it. A new RFC, Bound-Erased Generic Types, wants to turn those comments into real syntax. Let's start with what a generic even is, then look at why PHP has fought this for a decade. A 30-Second Theory Refresh A generic is a type with a hole in it...
Read the original article