Doxygen does not document php code internally if tags

I'm using doxygen, but it doesn't document some of my classes. All of these classes are called like this:

<?php
if(!class_exists('a')){
    class a{

        function b(){
            print 'c';
        }
    }
}
?>

      

I'm guessing it has something to do with if (! Class_exists ('a')), how can I let doxygen still document this?

+2


source to share


1 answer


Doxygen has many problems documenting php code. And many of them can be fixed with input_filter

.

Use the following code as a filter

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

      

and enter it like

/path/to/php php_var_filter.php

      



into the setting input_filter

.

Note. In this way, you can correct many oxygen problems. If something doesn't work it has to do with the difference between c (or c ++) code and php code (most similar). You can use input_filter to change your php code to look more like c code. This will fix many problems.

Edit
Perhaps you also want to think about the autoload function. I think this is the best way to get if(!class_exists(..))

-result.

Edit I just noticed that I have already answered another question in a different way. You can use this answer as well .

You can find some more input filters to improve doxygen php support on GitHub .

+1


source







All Articles