PHP is finally embracing the "TypeScript model" by prioritizing static analysis over runtime overhead. It is a pragmatic, long-overdue evolution that acknowledges developer experience is more important than architectural purity.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
PHP Is Finally Getting Generics...Added:
All right, maybe not that official, but it's under discussion. It's literally under discussion. We may actually get generics on PHP. On PHP P. I'm super excited about this. On this video, we are going to discuss everything on this RFC and what this can mean. Now, diving into this stuff. First of all, what is an RFC? RFC is basically a proposal to the PHP language itself.
The author of his RFC is actually the creator of MAGO who have proposed bound generic types to the PHP language. Okay, what is generics to begin with? We kind of already have generics in PHP. Okay, at the minute they work through PHP annotations, meaning that if I were to process this given value, PHP knows that the return type will be from the same value of the given argument. meaning that I'm not able to sum the given string nun maduro with a value one. So I get that information through PHP stand.
Okay. So potentially here if I process one, PHP knows that the t value returned will be an integer. Therefore I will fix this issue. So we already have generics a little bit on PHP but they work through PHP annotations and people were not happy about that. Now what this RFC proposes it's literally have real generics in PHP meaning that instead of having this crap right here you would be able to come here and say this function is generic and that generic type is called a t value and the gim type of value as an argument will be the same type of value returned. This is literally what this RFC is proposing.
Now one question you may have is what means bound erased? Okay, I'm going to explain you exactly what this means.
Boundary means that the definition of generics won't actually carry to the runtime. Meaning that for PHP, and I repeat, for PHP, not static analysis, but for a PHP at runtime, this function will be actually something like this.
Okay, will be exactly like this. Things won't actually change at runtime.
However, for static analysis things like PHP stamp, solve or maggo, they will be actually able to read this definitions and perform static analysis on this code. This effectively means the following. If I were to go to this code right here and I were to for example return value with return no at runtime, this code would just work. It would compile. It wouldn't actually tell you an error. However, if you use PHP stand, PHP stand will complain about this function because the return type actually depends of the given T value. I hope this was a little bit clear. And by the way, this is not something new.
There is a lot of languages who have implemented generics this way. Python is one of them. Now, one of the many reasons I'm very very excited about this new RFC is that existing code will be able to implement generics without being a breaking change. That's very exciting.
Meaning that classes like Laravel collection, they can effectively implement generics in this new approach without that being breaking. Meaning that I can come here and say this will have a generic type T key but also a generic type T value. And by doing this this won't break existing applications because the definitions won't carry to runtime. However, for static analysis, things will continue to work like before because having this new syntax is effectively a little bit equivalent to the previous syntax through PHP annotations. Now this is super important to make sure the PHP ecosystem moves forward and moves forward together.
Meaning that things like Laravel, Symfony and all the existing ecosystem will be able to implement generics in this new way without being breaking for every single application out there. And of course, everyone is super excited about this. Just check this out.
Literally, everyone is putting thumbs up. And I'm going to do the same right here. However, we're talking about 400 files changed. So obviously that is a lot of changes. Okay, there is a lot of changes on this RFC. So, this may actually take a while and actually may be up for a huge discussion. So, I'm going to keep yourself up to date on this one, but there is a potential of not actually being approved for this next PHP version. But everything is there. However, man, I'm just so excited about this. Just look at this beauty.
We're talking about PHP actually have generics. Beautiful generics, my friends, being implemented in the same way as Typescript, as Python. I'm very excited about this.
Now, it's worth to mention that this RFC is not as simple as it seems. Meaning that if eventually this were to come to PHP 8.6, every single piece of the ecosystem needs to adapt to generics, meaning that IDs, things like PHP storm will need to support this new syntax. I I don't see a problem on that, but it may take a little bit. Also static analysis we're talking about things like maggo will need to adapt PHP stand will need to adapt s and other static analysis will need to adapt but also many other things like debuggers coverage reflection so all that stuff will need to support generics and funny I just saw past php being mentioned on this RFC which is very very interesting but even things like llinters and everything will have to adjust to generics and that actually may take a little bit now it's worth to mention as tell that this RFC it's intentionally leave out of the scope things like arrays okay in itables as well. I would love to see this RFC also have support for generics and things like arrays.
However, I do understand that having that as well on this RFC may put the RFC in doing too much stuff. And we know historically that when an RFC have too much stuff typically doesn't get approved. So this RFC is literally generics just for classes and functions if I'm not mistaken. Now of course very important as usual just like any other RFC if eventually this were to move forward uh we will need to have two out of three majority uh accepting this RFC and this will obviously be targeting PHP 8.6 which will be released by the end of the year. If you want to read more about this, I'm going to publish all the links to this RFC, the links to the GitHub pull request as well down on the comments below. Now, it's worth to mention that we are already getting a few things for PHP 8.6. However, in my opinion, nothing comes even close to the excitement around generics if we were to have them. Now, obviously, I'm very thankful for all the contributors to the PHP language and the creator of this RFC. It's called it Cified, the creator of Mago. So, thank you so much, Cified.
I apologize if I'm pronouncing your name incorrectly, but thank you so much for this. He is actually the creator of Maggo, which is a static analysis, a link formatter for PHP written in Rust.
I have a full video on that topic right here in case you want to see what is Maggo. And write on the comments below what do you think about this new RFC. I want to see your comments about this new addition. If you want to see what we had on PHP8.5, don't forget check out this video. It's a beautiful video about everything we had on PHP.5. Love you all and peace out.
Related Videos
Agentforce NOW AMA: Build with React and Salesforce Multi-Framework
SalesforceDevs
490 views•2026-05-28
How agent o11y differs from traditional o11y — Phil Hetzel, Braintrust
aiDotEngineer
450 views•2026-05-28
WEB TECHNOLOGIES UNIT-2 | Degree 4th sem BCOM Computers web technologies unit-2 full explanation💯✅
LearnwithSahera
1K views•2026-05-29
More tests are always better? How to use AI to identify tests that bring little value
Alliance4Qualification
335 views•2026-05-29
Search Algorithms Explained in 60 Seconds! 🤖💨
samarthtuliofficial
218 views•2026-06-01
People of Game of Thrones using JavaScript DOM
AltCampus
296 views•2026-05-30
Introduction to Problem Solving Part - 1 | Lecture 1 | Intermediate DSA
ascensionix
107 views•2026-05-29
🚀 BCS613C Compiler Design | Module 1 to 5 Schema Evaluation 🔥 | VTU 6th Sem 💯 #VTU #bcs613c #exam
Pranavaa-y4y
104 views•2026-06-02











