Check class_exists before class definition / Doxygen problem

It looks like doxygen has some problems with such code, but… There are some solutions…

You can use INPUT_FILTERs for that. After doxygen docs:

The INPUT_FILTER tag can be used to specify a program that doxygen
should invoke to filter for each input file. Doxygen will invoke the
filter program by executing (via popen()) the command:

So you can use this script as a filter (as suggested in this answer: https://stackoverflow.com/a/26206860/217040):

<?php
    $source = file_get_contents($argv[1]);
    $regexp = '#(<\?php[\s]+)(if\(!class_exists\([^\)]+\)\)\{)([\s\S]*)(\})([\s]*\?>)#';
    $replace="$1 $3 $5";
    $source = preg_replace($regexp, $replace, $source);
    echo $source;
?>

Or another one (https://stackoverflow.com/a/25655189/217040):

// 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;