I am creating a collection class and would like it to be drop-in-replacement for arrays, which I use currently.
How to create a class which could be casted
You cannot.
In PHP an object when cast to bool always produces true. There is no way of changing that.
bool
true