Less memory-consuming way to detect array recursions

I had issues (segmentation-faults) with the array-recursion-detection when $data was a large array (without recursions). This was already mentioned sometimes (e.g. http://stackoverflow.com/questions/6343674/phpunit-segmentation-fault).

I changed the detection to use http://php.net/manual/en/function.count.php, which triggers an E_WARNING when it detects a recursion.