You can define generic types in PhpDoc annotations, and since you have static analysis in your CI process and corresponding syntax support in your IDE, you have generics in your project.
There's no bloat anywhere. It's just static analysis.
“We don’t need actual proper functionality, because we can inconsistent bloat to our applications and pretend we do!”
...said in a discussion where it's being discussed that PHP folks do in fact want generics in the language. FYI I'm pretty sure the internals people also want this but it's prohibitively complex to implement or it would have been present already years ago.
I beg your pardon? I don't think I'm the one not behaving here.
Anyway, no, there "is" extra packages to install. But it depends what you mean by "packages": they aren't part of your application - you don't deploy them.
It’s bloat relative to having the actual functionality, and in terms of your development process.
Install these extra packages, and add all this configuration, and this extra stage to your CI just so you can pretend you have the functionality. Whoop de doo.
Oh, and by the way, it still won’t work properly, because it can’t actually follow your logic, so you’ll have to add a load of fluff just so your pretend functionality pretends to function.
So something like a poor man’s generics.. and if you delete those “comments” this functionality is gone from your code. I get your point and code with annotations is much better to work with but there is a big BUT..
My main issues is that some of us are acting like “you can almost achieve generics with annotations as phpdoc”. Comments are not code. I know generics are currently almost impossible to achieve in php, and as I wrote that’s not the issue here. Static analysis is just a bandage although a helpful one.
View all comments
Show parent comment
0
u/viktorprogger Dec 29 '24
With static analysis tools like Psalm generics are kind of present in PHP.