Doxygen: how to describe class member variables in php?
I am using an input filter to insert typehints from the @var annotation inline with variable declaration, and remove the @var annotation as it has different meaning in Doxygen. For more info, see bug #626105.
As Doxygen uses C-like parser, when the input filter is run it can recognize types.
<?php
$source = file_get_contents($argv[1]);
$regexp = '#\@var\s+([^\s]+)([^/]+)/\s+(var|public|protected|private)\s+(\$[^\s;=]+)#';
$replac = '${2} */ ${3} ${1} ${4}';
$source = preg_replace($regexp, $replac, $source);
echo $source;
This is a quick hack, and probably have bugs, it just works for my code:
You can enable input filter with INPUT_FILTER option in your Doxyfile. Save the code above to file named php_var_filter.php and set the filter value to "php php_var_filter.php".
I had the same problem, so I've created a simple input filter which turns the basic syntax of
/**
* @var int
*/
public $id;
into
/**
* @var int $id
*/
public $id;
which would be redundant anyway. This way the Eclipse IDE can use the same docblock as doxygen.
You can download the input filter from here:
https://bitbucket.org/tamasimrei/misc-tools/src/master/doxygen/filter.php
See the doxygen Manual on how to use an input filter.
The tool also escapes backslashes in docblocks, so you could use namespaces there.