【问题标题】:What is the correct way to document PHP constants (define) with phpDocumentor用 phpDocumentor 记录 PHP 常量(定义)的正确方法是什么
【发布时间】:2011-01-12 15:50:38
【问题描述】:

我们必须如何记录(使用phpDocumentor)在 PHP 中用define() 定义的常量?

我在文档中一无所获,但在 sample2.php 中找到了以下示例(我没有看到它的用途):

/**#@+
 * Constants
 */
/**
 * first constant
 */
define('testing', 6);
/**
 * second constant
 */
define('anotherconstant', strlen('hello'));

谁能告诉我用 phpDocumentor 在 PHP 中记录常量的最佳方法是什么?

【问题讨论】:

    标签: php constants phpdoc


    【解决方案1】:
    /**
    *@const
    */
    const testing=6;
    const anotherconstant=strlen('hello');
    

    试试这个,你会看到它是不变的

    【讨论】:

      【解决方案2】:

      Define 语句通常仅使用描述性文本进行注释,因此基本上就是您对其进行注释的方式。

      要了解有关 DocBlock 模板标签 /**#@+ 的更多信息,请查看 the manual page

      【讨论】:

      • 不需要特定的标签。出现在示例顶部的“模板标签”仅作为快捷方式将您的“常量”描述片段添加到每个单独的描述中(“第一个常量”、“第二个常量” )。仅当您确实想将一些常用文本放入多个单独的描述中时,才需要使用该模板标签。
      • 所有链接都失效了
      【解决方案3】:

      你在 phpDoc.org the elements that can be documented.

      你还有an example of documenting a define()(第二段代码和周围的段落)。

      【讨论】:

      • 该示例实际上试图证明将“define”语句错误地夹在函数 foo() 和函数的 docblock 之间会导致 docblock 错误地与定义的常量而不是函数相关联。我真的没有在教程中看到一个有用的例子来显示记录一个常量,所以我在 phpDocumentor 的文件本身中找到了一个......在此处查看页面底部(manual.phpdoc.org/HTMLSmartyConverter/HandS/__filesource/…)。
      • 所有链接都失效了
      • 项目更改了文档的位置。新位置:phpdoc.org/docs/latest(对不起,我找不到我发布的部分)
      猜你喜欢
      • 2011-06-27
      • 1970-01-01
      • 2019-10-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-04
      • 2010-11-11
      • 1970-01-01
      相关资源
      最近更新 更多