no global please. There are better way to pass context to closures.

This code is not working either, because of using ``static`` in the closure (at least in PHP 5.3. I know ``self`` works in closures on 5.4 but I'm not sure about ``static``).

And this would not restore the error handler properly because of the exception stopping the execution. You need to catch the exception, restore the error handler for the invalid case and rethrow the exception.
The code using the comparison with ``false`` may be simpler than using an error handler the right way