Track usage of features marked for deprecation

Following this topic: How to handle obsolete functions in the library? I want to find a way to track all calls to an obsolete function so that I can make sure they are all replaced before the function is deleted. Given the following PHP methods

/*
   @deprecated - just use getBar()
*/
function getFoo(){
    return getBar();
}

function getBar(){
    return "bar";
}

I came up with the following way to do this, and I'm looking for feedback.

function getFoo(){
    try{
        throw new Exception("Deprecated function used"); 
    } catch(Exception $e){
         //Log the Exception with stack trace
         ....
         // return value as normal
         return getBar();
    }
}
+5
source share
2 answers

For internal obsolete PHP functions, just add E_STRICT to error_reporting .

, @deprecated, E_USER_DEPRECATED,

function getFoo(){
    trigger_error(__FUNCTION__ . 'is deprecated', E_USER_DEPRECATED );
    return getBar();
}

, - QA , . , .

, TDD 100% . , , .

+4

, - 100% , , . , .

, File > Search in Files

IDE - , PHP, .

Afterthought: , PhpXRef - .

+1

All Articles