I was not even lucky with Runkit.
You asked for alternatives, and I can definitely recommend this:
Patchwork
Patchwork is a PHP function override library. In other words, it does the same job as Runkit.
The main difference is that it is written in pure PHP - no extensions to install; just require_once() at the top of your code.
The reflective side of this is that since it is pure PHP, it can only replace the functions defined in your program; those. it cannot override a PHP built-in function such as Runkit. The example in your question will work just fine with Patchwork, but trying to override a PHP function like mysql_query() is not possible.
However, unlike Runkit, it works just fine, so if you can live with this limitation, I highly recommend it.
Another Runkit alternative you can try is the PHP Help Helpers . This is an extension of PHP and covers almost the same foundation as Runkit. It is written by the same author as PHPUnit, so this should be very good. However, I did not have much joy when I tried to fix this, so I cannot comment on it.
I remember your comments elsewhere on this subject that you are using Windows (i.e. WAMP). Neither Runkit nor PHP Test Helpers provide Windows executables; To use any of them on Windows, you need to compile the extension yourself from the C source code. For this reason, if you are working on Windows, then Patchwork is your only reasonable choice.
source share