I am in the process of documenting a PHP project using PHPDocumentor2. Ironically, PHPDoc's documentation isn't overly detailed. I fully understand how to comment files, classes, functions and variables, however if a variable or constant is being defined within an if statement how should I comment it?
Example:
if ($foo==$bar) {
define('FOOBAR',$foo);
} else if ($foo>$bar) {
define('FOOBAR',$bar);
} else {
define('FOOBAR',$foo+$bar);
}
Clearly I don't want to add 3 comments, and the documentation should really explain the if statement so logically the docBlock ought to go before the start of the if statement - this would be most aesthetically pleasing in code view - but the docBlock has to be on the line immediately before the "define". I can put it before the first one, but that looks odd.
if ($foo==$bar) {
/**
* FOOBAR Definition.
*
* Value of FOOBAR. Yada yada.
* @var int
*/
define('FOOBAR',$foo);
} else if ($foo>$bar) {
define('FOOBAR',$bar);
} else {
define('FOOBAR',$foo+$bar);
}
Any ideas?