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
<?php if(!class_exists("FooBar")) // This comment will also disappear { /** * This is documentation for the class FooBar */ class FooBar { /** * Documentation for FooBar\'s constructor */ public function __construct() { ; } } } // class_exists
into
<?php /** * This is documentation for the class FooBar */ class FooBar { /** * Documentation for FooBar's constructor */ public function __construct() { ; } }
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.
ifblocks) is a really, really bad idea. If you have a large/complex code base then you should be using namespaces to organize your code. In other words, you should not be trying to somehow force Doxygen to handle bad practices; you should not be using bad practices to begin with.