I am trying to document my code more often and now I'm writing a class and want it to be fully documented. However, for some strange reason, local variable documentation (with PHPDoc of course) doesn't work..
I got this:
/**
* A function for question
* @param string $theVar The var to put in local var $aVar.
*/
public function theFunction($theVar) {
/** @var string This is new local var, should have documentation but hasn't... */
$aVar = $theVar;
}
So when I type 'the' and press space, and go to my function in Netbeans, it shows the function documentation.
But, when I type 'aVa' inside the function and press space and go to my variable, it says 'PHPDoc not found'.
I know in this case it wouldn't be a problem, but in a big function with lots of code it could actually be useful. However, for some reason it doesn't work and I have no clue why.
I don't think you can document internal variables like that. You can document class
variable declarations and function parameters but the documentation doesn't say anything about a local function variable
You may use the @var tag to document the “Type” of properties, sometimes called class variables. Examples
class Foo
{
/** @var string|null Should contain a description */
protected $description = null;
}
Even compound statements may be documented:
class Foo
{
/**
* @var string $name Should contain a description
* @var string $description Should contain a description
*/
protected $name, $description;
}