[phc-general] Statical code analysis (metrics) with PHC
Edsko de Vries
edsko at phpcompiler.org
Sun Nov 25 22:00:13 GMT 2007
> - I want to execute code analysis over a large code base consiting
> of hundrets of php files and lets say about a million lines of
> code. The count statements plugin works on a single file. Is
> there an easy possibility of using the plugin on multiple files
> (exept using some shell/awk stuff like
> find . "*.php" |xargs phc --run=myplugin | awk ... asf.
Further to Paul's suggestions, it would also be quite easy to write a
plugin that visits a large number of files, parsing them (one the last
tutorials shows how to invoke the phc parser) and then calling a visitor
on them. That way you can do everything within your program and collect
statistics etc without having to pipe things through multiple apps.
> - Which other plugins are known today for statical code analysis, like
> - number of classes
> - number of methods
> - average number of lines of code per class or method
> - ... ?
Very few. The ones that are there (like the count statements) are merely
to illustrate a point. However, analyses such as the ones you mention
above should be very easy indeed to code up as plugins.
> - Are there known any phc based projects related to the issue of
> statical code analysis? Can you link me to some further
> information in case you have some available.
> By the way, I would also be glad to get some hints for statical
> analysing tools for PHP which might not be based on phc (except the
> Code Analysing feature of Zend Studio, which is more then nothing,
> but not even more then just more ...).
I'm not sure what exactly what you are looking for, but both
both try to do static analyses on PHP scripts. Sadly, neither is based
on phc :)
More information about the phc-general