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 can take a look at the PHP operator extension which you can use to overload many operators including == and ===. With this extension, you should be theoretically able to write a class comparable to boolean values like this:
if($object == true)