📐Type TheoryDEV CommunityContent type: Blog

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
Sign in to keep reading the full article.

Keyboard Shortcuts

Navigation

Next / previous post
j/k
Open post
oorEnter
Preview post
v

Post Actions

Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Save / unsave
s

Recommendations

Add interest / feed
Enter
Not interested
x

Go to

Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Discover
gb
Search
/

General

Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help