phpdoc:记录常量的正确方法是什么

发布于 2024-10-17 03:39:36 字数 93 浏览 10 评论 0原文

是否有正确的方法来记录使用 define() 定义的常量? @var 确实没有意义。我唯一能想到的就是省略标签,只在 PHPdoc 注释中写描述。

Is there a proper way to document a constant defined using define()? @var doesn't really make sense. The only thing I can think of is to omit the tag, and just write the description in the PHPdoc comment.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

如果没结果 2024-10-24 03:39:36

phpDocumentor 无法识别或使用 @const 标签。当 phpDocumentor 在代码中看到“define”关键字时,它会识别出一个常量。其输出模板将显示输出文档中的所有常量,列为常量。常量的文档块中唯一需要的是描述,尽管如果您觉得需要它们,也可以使用许多其他“标准”标签 [1]。

[1] -- http://manual.phpdoc。 org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_elements.pkg.html#procedural.define

phpDocumentor does not recognize or utilize a @const tag. phpDocumentor recognizes a constant when it sees the "define" keyword in the code. Its output templates will show all constants in the output documentation, listed as constants. The only thing needed in the constant's docblock is a description, although many other "standard" tags are allowed if you feel like you need them [1].

[1] -- http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_elements.pkg.html#procedural.define

挖鼻大婶 2024-10-24 03:39:36

使用@const。

/**
  * @const FOO Bar
  */
define('FOO', 'Bar');

文档(抱歉,我能找到的唯一文档是德语的。)

Use @const.

/**
  * @const FOO Bar
  */
define('FOO', 'Bar');

Documentation (Sorry, the only docs I can find are in German.)

挽容 2024-10-24 03:39:36

您实际上想使用 @type,请参阅 Github PHP 文档

You actually want to use @type, see the Github PHP Documentation.

枯寂 2024-10-24 03:39:36

如果您根本不使用任何标签并直接写入文本,我的 phpDocumentor 版本(2.9.0)实际上会显示文本。不过,它被视为函数/方法头:第一行是摘要,其他所有内容都是描述。

/** 
 * The meaning of life.
 */
const MYSTERY = 42;

此外,我可以确认 @const@type “有效”,因为文本出现在“标签”下的侧边栏中,而不是直接位于主内容中的常量下方柱子。

My version of phpDocumentor (2.9.0) actually shows text if you don't use any tag at all and write the text directly. Though, it's treated like a function/method header: first line is a summary and everything else is the description.

/** 
 * The meaning of life.
 */
const MYSTERY = 42;

Furthermore, I can confirm that @const and @type "work" in that the text appears in a sidebar under "Tags" – rather than directly underneath the constant in the main column.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文