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
If you don't want to implement your own method you could hack your way into __toString, like this:
__toString
class foo { public function __toString() { return strval(false); } } $foo = new foo(); if (strval($foo) == false) // non-strict comparison { echo '$foo is falsy'; } echo (bool) strval($foo); // false