php - Netbeans PHPDoc 局部变量不起作用

标签 php netbeans phpdoc

我正在尝试更频繁地记录我的代码,现在我正在编写一个类并希望对其进行完整记录。然而,由于某些奇怪的原因,局部变量文档(当然使用 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/

相关文章:

php - 在 PhpStorm 中标记 @see

php - 如何在 PhpStorm 9 for Blade 模板中使变量自动完成?

javascript - 传递 id 来具体化模态 laravel

php - 在自定义插件类中使用 Carbon Fields

php - Laravel PageController 最佳实践

c++ - undefined reference

java - 为什么来自 Netbeans 的 Java 8 会劫持在我的浏览器中运行的 Java 7?

Aptana 不会为类中的函数生成 phpdoc block

php - 有关 PHP 和 MySQL 函数的帮助

java - 在 NetBeans 上 Play Framework 第一个项目无法正常工作