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
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.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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
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.