This new release of PHP_Depend took some time to be finished. This is because the initial idea of a simple adaption of JDepend evolved (supported thru this blog-post by Sebastian), and so PHP_Depend has become a complete software metric application. Many new features and enhancements have found their way into this version. One of the key features is the pluggable architecture for custom Loggers and Metric-Analyzers. This opens the possibility to hook own Logger- and Analyzer-implementations into the execution chain of PHP_Depend. Beside these architectural changes this PHP_Depend version is shipped with a large set of implemented software metrics.
ClassLevel (Class)
- dit: Depth of Inheritance Tree
- impl: Number of implemented interfaces
- cis: Class Interface Size
- csz: Class SiZe
- vars: Number of defined class properties
- varsi: Number of own and inherited class properties
- varsnp: Number of public class properties
- wmc: Weighted Method per Class(Sum of method Cyclomatic Complexity)
- wmci: Weighted Method per Class + inherited WMC
- wmcnp: Weighted Method per Class for all public class methods
CodeRank (Class, Package)
An adaption of google's PageRank algorithm for classes and packages.
- cr: Forward CodeRank (based on incoming edges)
- rcr: Reverse CodeRank (based on outgoing edges)
Coupling (Project)
- calls: Number of called methods and functions
- fanout: Number of referenced types
Cyclomatic Complexity (Project, Method, Function)
- ccn: Cyclomatic Complexity
- ccn2: Extended Cyclomatic Complexity
Dependency (Package)
For details see the following entry.
- ca: Afferent coupling
- ce: Efferent coupling
- a: Abstraction
- i: Instability
- d: Distance
Hierarchy (Project)
- clsa: Number of abstract classes.
- clsc: Number of concrete classes.
- roots: Number of root classes within the analyzed system.
- leafs: Number of leaf classes.
- maxDIT: Max Depth of Inheritance Tree value
Inheritance (Project)
- andc: Average Number of Derived Classes.
- ahh: Average Hierarchy Height
NodeCount (Project, Package, Class, Interface)
- nop: Number Of Packages
- noc: Number Of Classes
- noi: Number Of Interfaces
- nom: Number Of Methods
- nof: Number Of Functions
NodeLOC (Project, Package, Class, Interface, Method, Function)
- loc: Lines Of Code
- cloc: Comment Lines Of Code
- ncloc: Non Comment Lines Of Code
Due to the fact that PHP is a loosely typed programming language, PHP_Depend can only approximate some values. But the measured results can be improved with a good and complete source code documentation, because PHP_Depend takes advantage of different doc comment annotations (@throws, @var, @return). So I suggest the use of a tool like PHP_CodeSniffer, to achieve better results.
Beside all these metrics, PHP_Depend also provides a new chart type, the "Overview Pyramid". The Overview Pyramid can be a handy tool to analyze legacy code. If you have read the book Object-Oriented Metrics in Practice you should know howto interpret the Overview Pyramid, all others have to wait for a detailed description.
This new version can be installed with the PEAR-Installer. Just discover the pear.xplib.de channel and install the latest PHP_Depend release.
After PHP_Depend has been installed successfully, the new command line tool pdepend should exist.
mapi@arwen ~ $ pear channel-discover pear.xplib.de
mapi@arwen ~ $ pear install xplib/PHP_Depend-beta
mapi@arwen ~ $ pdepend --help
PHP_Depend 0.8.0beta1 by Manuel Pichler
Usage: pdepend [options] [logger] <dir[,dir[,...]]>
--jdepend-chart=<file> Generates a diagram of the analyzed packages.
--jdepend-xml=<file> Generates the package dependency log.
--overview-pyramid=<file> Generates a chart with an Overview Pyramid for the
analyzed project.
--summary-xml=<file> Generates a xml log with all metrics.
--coderank-mode=<*[,...]> Used CodeRank strategies. Comma separated list of
'inheritance'(default), 'property' and 'method'.
--suffix=<ext[,...]> List of valid PHP file extensions.
--ignore=<dir[,...]> List of exclude directories.
--exclude=<pkg[,...]> List of exclude packages.
--without-annotations Do not parse doc comment annotations.
--help Print this help text.
--version Print the current PHP_Depend version.
There is also a Subversion repository at http://svn.pdepend.org/, where the latest development version can be found.
Please test this beta release and file bug-reports and feature-requests in the PHP_Depend bug tracker.