根据这个帖子:如何处理库中的函数弃用? 我想找到一种方法来跟踪所有对被弃用函数的调用,以确保在函数被移除之前替换它们。给定以下PHP方法:
/*
@deprecated - just use getBar()
*/
function getFoo(){
return getBar();
}
function getBar(){
return "bar";
}
我想到了以下方法,并希望得到反馈。
function getFoo(){
try{
throw new Exception("Deprecated function used");
} catch(Exception $e){
//Log the Exception with stack trace
....
// return value as normal
return getBar();
}
}
debug_backtrace()
的数据-上面的示例故意保持简短以提高可读性。 - Gordon