我正在尝试更频繁地记录我的代码,现在我正在编写一个类并希望对其进行完整记录。然而,由于某些奇怪的原因,局部变量文档(当然使用 PHPDoc)不起作用..
我得到了这个:
/**
* 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;
}
因此,当我输入“the”并按空格键,然后转到 Netbeans 中的函数时,它会显示函数文档。
但是,当我在函数内输入“aVa”并按空格键并转到我的变量时,它显示“未找到 PHPDoc”。
我知道在这种情况下这不会成为问题,但在具有大量代码的大函数中它实际上可能很有用。但是,由于某种原因它不起作用,我不知道为什么。
最佳答案
我认为你不能像这样记录内部变量。您可以记录 class
变量声明和函数参数,但是 the documentation没有提及任何有关局部函数变量的内容
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;
}
关于php - Netbeans PHPDoc 局部变量不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33126223/