On his blog, Maarten Balliauw shows two easy ways on how to implement an ArrayObject supporting generics in PHP5:
Assuming everyone knows what generics are, let’s get down to business right away. PHP does not support generics or something similar, though it could be very useful in PHP development. Luckily, using some standard OO-practises, a semi-generic array can easily be created, even in multiple ways!
Using the provided sample code, one can easily implement an ArrayObject supporting only one type of object, i.e. an ArrayObject of which you can be 100% certain that it only contains for example "Person"-objects.
The post Generics in PHP appeared first on Zend Developer Zone.