I am writing relatively complex PHP applications and have several files for class definitions formatted as follows:
As mentioned by @Sverri in the comments, I also think that autoloading is a good way to solve your problem (what it already did, as it seems).
But just for the case you (or someone else) is looking for a doxygen-only solution:
You can use INPUT_FILTERS in doxygen to remove or change some parts of the source code before creating the documentation.
You can use the following php code to remove all lines containing if(!class_exists
and the braces {
}
that belong to this if
-block, as long as it is not followed by another block.
// input
$source = file_get_contents($argv[1]);
// removes the whole line
list($head,$tail) = preg_split('/.*if\(!class_exists\(.+/', $source, 2);
$openingBracePos = strpos($tail,'{');
$closingBracePos = strrpos($tail,'}');
if($openingBracePos !== false && $closingBracePos !== false)
$source = $head . substr($tail,$openingBracePos+1,
$closingBracePos-$openingBracePos-1);
echo $source;
This filter truns
into
Note: On windows I have to call the filter like this: C:\xampp\php\php.exe php_var_filter.php
You can find some more input filters to improve doxygen's php support on GitHub.