2

I'm trying to document PHP class members with Doxygen (I'm not using PHPDocs because the project involves COCOA programming, so I can use the same tool for both parts).

/**
 * This is brief description. 
 *  
 * This is detailed description.
 */
 private $foo;

This code gets the documentation done right, but I would like to include in the docs the type the var should handle.

I tried to use \var and \property, but then Doxigen does not generate the doc for the var.

 //THIS IS NOT WORKING!
 /**
 * This is brief description. 
 *  
 * This is detailed description.
 * \var int 
 */
 private $foo;

I have seen this post: Doxygen: how to describe class member variables in php?

Seems that \var is not working in Doxyegn, but the post is a bit old and maybe there is something I can do now.

Community
  • 1
  • 1
David Casillas
  • 1,801
  • 1
  • 29
  • 57
  • 1
    From the [discussion](https://bugzilla.gnome.org/show_bug.cgi?id=626105#c6) linked to from the PHP + Doxygen question you mention it seems that you have to include the variable name on your `\var` line, for example `\var int $foo`. Of course having additional, redundant documentation is alway best avoided. – Chris Feb 03 '12 at 08:46
  • 1
    possible duplicate of [Doxygen: how to describe class member variables in php?](http://stackoverflow.com/questions/4325224/doxygen-how-to-describe-class-member-variables-in-php) – Toon Krijthe Feb 06 '12 at 08:53

3 Answers3

6

I have follow the bug comments of this feature:

https://bugzilla.gnome.org/show_bug.cgi?id=626105.

In comment number 6 a solution is proposed, adding the var name after the type.

class Mine {
   /**
    * Definition of variable
    * @var string $var
    */
   private $var = array();
}

This is working for me.

David Casillas
  • 1,801
  • 1
  • 29
  • 57
0

Simple workaround which generates acceptable results is to add this input filter:

INPUT_FILTER = "sed -e 's/@var\s/@see /'"

Or even better to define an alias:

ALIASES += "var=@see"

It simply replaces @var command with @see command. It is not perfect, but it is very simple and relatively bulletproof.

Small disadvantage is that the type is somewhere in the description instead of the heading. On the other side, if only few properties has type defined, it makes documentation more consistent (headings look the same).

Josef Kufner
  • 2,851
  • 22
  • 28
0

@type works for me:

    /** @type string[] */
    private $csvData;

    /**
     * command line parameters
     * @type string[]
     */

    private $parameters;
ob-ivan
  • 785
  • 1
  • 8
  • 17