I would like to overwrite a couple of functions that are already declared in PHP. The application I am working with is full of legacy code (including calls to eval()) so just replacing the identifier where the functions are called in the code might not be enough.
Is it possible to change a function that has already been declared, without using the Advanced PHP Debugger in PHP5?
Yes, by using
runkit_function_redefine— Replace a function definition with a new implementationIt’s a PECL extension and can be installed via PEAR. But keep in mind that redeclaring functions does not substitute for proper refactoring. You are just exchanging one evil for another.
Also see Is it possible to replace (monkeypatch) PHP functions?