PHP Depend - Software Metrics for PHP

What is PHP_Depend?

Since there is much confusion about what PHP_Depend is or is not, this section will give a short description about the things PHP_Depend can do and how they can improve your development process.

Introduction

PHP_Depend is a small program that performs static code analysis on a given source base. Static code analysis means that PHP_Depend first takes the source code and parses it into an easily processable internal data structure. This data structure is normally called an AST (Abstract Syntax Tree), that represents the different statements and elements used in the analyzed source base. Then it takes the generated AST and measures several values, the so called software metrics. Each of this values stands for a quality aspect in the the analyzed software, observed from a very high level of abstraction, because no source was reviewed manually until now.

What is a software metric?

Okay, so what are these software metrics? Normally software metrics are really simple things. They are just the sum of some statements or code fragments found in the analyzed source. For example, the Cyclomatic Complexity or CCN of a method is just the sum of all logical statements, like if, for etc., in the analyzed method. This means a Cyclomatic Complexity value of 23 only says that there are 23 statements in the analyzed method. You can now take this value and compare it with your own or others experience, when a piece of software gets unmaintainable due to its complexity.

And why should I use PHP_Depend?

That's a really good question! Why should you use a just another tool in your daily development process to perform such a simple task like building source statistics? The answer is easy.

Conclusion

Software metrics as they are provided by tools like PHP_Depend are really useful utilities to improve the productivity of development- and quality-assurance-teams. But metrics are only indications for possible problem areas. But they are just indications and no holy grail you should follow blind.

Build on CloudBees button