DEV Community

Discussion on: PHP needs its own ES6

Collapse
 
dopitz profile image
Daniel O. • Edited

Generics would be cool. On the other hand, it is already possible since PHP 7 to collect values of a single datatype. Just create a class and use type hinting. Here is an example: 3v4l.org/EKmWb

Collapse
 
aleksikauppila profile image
Aleksi Kauppila

This actually the approach i've been using for quite some time now. I usually just implement IteratorAggregate and create adding methods. Still, this usually means that i implement a lot of these classes. Lots of repetition, lots of new files.