PHP_UML is a reverse-engineering tool, and a documentation tool.
It can parse PHP files and directories, and generate:
An XMI file, reflecting the object structure of the code parsed; you can then import that file into a CASE tool (such as Rational Rose)
A full HTML API documentation, very similar to Javadoc
PHP code skeletons (useful if you have an existing XMI file, and want to generate the files, folders and class declarations all at once)
XMI is an OMG standard for exchanging metadata information via XML, and is commonly used as an interchange format for UML models. Many UML softwares support importing and exporting of XMI files.
Like PhpDocumentor, PHP_UML can parse the following PHP elements: namespaces, classes, interfaces, properties, and functions. It can also retrieve information from the inline comments, via the docblocks: @package, @var, @param
@param and @var learn PHP_UML about the expected types of a parameter or a property.
@package learns PHP_UML about the namespace of an element (even if, from PHP 5.3, it is recommended to use the PHP namespacing instructions instead)
So the more documented your PHP code is, the more precise your XMI file, or your API documentation, will be.
At the current time, the UML/XMI standards exist in two distinct families of versions, 1.x and 2.x. PHP_UML can generate XMI in version 1.4, as well as in version 2.1. Be warned, though, that some UML tools might not interpret accurately the data contained in your XMI file. For example, the link between a UML artifact (a source file) and the classes defined inside that artifact is only available from version 2 of UML.
PHP_UML can also convert existing UML/XMI data from version 1.4 to version 2 (simple conversion).
You can use PHP_UML either from command line, or by writing a piece of code that will exploit the API.
Parsing a single file test.php, and generating its XMI file:
$uml = new PHP_UML();
$uml->generateXMI(1); // UML version number (1 or 2)
Your UML/XMI code might be interpreted differently by the modeling tool you are going to use along with PHP_UML. This is particularly true for the version 2 of UML/XMI. For instance, the Eclipse plug-ins (EMF, Papyrus) only accept a particular flavour of XMI, called ecore, which is only partly compatible with the one you will get with PHP_UML.
PHP_UML is designed with evolution in mind. By choosing XMI as the pivot format for representing object oriented program structures, PHP_UML can not only interface with many design tools. It can also be transformed, through XSLT, into many other formats, like the HTML API documentation generator, included in PHP_UML.
To start your own transformation, create a folder under /Output, and create a main.xsl file inside (you can copy the one in /Output/html). Run the method PHP_UML->export(), passing the name of your format as the first parameter.
Instead of transforming XMI code, another way to create new output formats is to write a PHP class that will directly exploit the metamodel that the parser has built, exactly like the package XMI does.
If you are interested by the PHP_UML project, and want to participate, do not hesitate to contact me.