2

I am using doxygen, but it doesn't document some of my classes. All these classes are called in the following way:

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

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

I assume it has to do with if(!class_exists('a')), how can i let doxygen still document this?

4
  • Have you tried putting a docblock above the class? Along with you, I'm guess that it has to do with the class being inside a control structure. Commented Oct 2, 2014 at 19:43
  • Yes i did, but i also setup doxygen to document undocumented structures. Commented Oct 2, 2014 at 20:11
  • Okay, I was curious. I use doxygen also, just not in the way you show above. I was thinking a docblock above the class would've forced it to document that structure. Commented Oct 2, 2014 at 20:25
  • This is a duplicate of this Question Commented Oct 6, 2014 at 13:45

1 Answer 1

1

Doxygen has many issues documenting php code. And many of them can be corrected by using an input_filter.

Use the following code as 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 as

/path/to/php php_var_filter.php

into the INPUT_FILTER setting.

Notice: This way you can fix many doxygen issues. If something does not work, it is beacause of a difference between c (or c++) code to php code (most likly). You can use the input_filter to change your php code to look more like c code. This will fix many problems.

Edit
Maybe you also want to think about an autoload function. I think this is a better way to get the if(!class_exists(..))-result.

Edit I just noticed I already answerd a similar question different. You can also use this answer.

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.