【发布时间】:2011-01-11 00:36:39
【问题描述】:
我使用phpDocumentor 的第一天到目前为止一切都很好,但是我有一个问题我没有在手册中找到...全局变量的文档。
如果出现以下情况,我将如何记录此代码:
- $someGlobalVar 在类的 PHP 文件中不是贴花(甚至可以取消声明)。
- $someGlobalVar 声明如下:$someGlobalVar = array();(不像 phpDocumentor 手册中那样使用超全局数组)。
PHP 代码:
class myCustomClass
{
private $someProperty;
//I want to document the use of global var in this method
public function getSomeProperty()
{
global $someGlobalVar;
if (isset($someGlobalVar))
{
//...
}
else
{
//...
}
}
}
编辑:我想按照手册所示记录这些全局变量,但我不确定如何/在何处放置 @global 和 @name 标签。
编辑 2: 我最终在声明 getSomeProperty 之前使用了以下 sn-p:
/**
* Get some property based on the $someGlobalVar global.
* @global array $someGlobalVar User defined array that bla bla bla.
* @return mixed Return a result bla bla bla.
*/
我使用 phpDocumentor 语法,以便NetBeans IDE 在源代码中显示内联帮助。在 NetBeans 中似乎一切正常,但我不确定这是否可行……
有人可以确认一下吗?
【问题讨论】:
-
好吧,我会通过不使用全局变量来解决这个问题 :) 但我认为这不是你想要的答案。
-
呵呵没错,但就我而言,我必须记录所做的事情:)
-
对于在谷歌上搜索问题的任何人,this thread seems to have a detailed answer.
标签: php global-variables phpdoc