views:

92

answers:

4

I have a large codebase which has suffered many changes over the years. I would like to remove the functions that are no longer called or relevant. Is there a tool that will analysis the codebase and determine if a method is ever used?

I'm also using phpunit/xdebug which reports which functions have not been run for the unit tests, however coverage is only at 55% and will require a massive amount of work to bring it up to 100% (I'm working on it!).

Anything that was a command line tool would be extra good as I could hook it into hudson (CI).

A: 

Netbeans? I know netbeans can do this.

WalterJ89
Just for private methods though.
Mikulas Dite
+3  A: 

Because PHP functions/methods can be dynamically invoked, there is no programmatic way to know with certainty if a function will never be called.

The only certain way is through manual analysis.

webbiedave
A: 

phpxref will identify where functions are called from which would facilitate the analysis - but there's still a crtain amount of manual effort involved.

C.

symcbean
A: 

afaik there is no way. To know which functions "are belonging to whom" you would need to execute the system (runtime late binding function lookup).

But Refactoring tools are based on static code analysis. I really like dynamic typed languages, but in my view they are difficult to scale. The lack of safe refactorings in large codebases and dynamic typed languages is a major drawback for maintainability and handling software evolution.

manuel aldana