phpDocumentor @global 和 @name 问题
第一天我使用 phpDocumentor ,到目前为止一切顺利,但我有一个问题,我在手册中没有发现...全局变量的文档。
如果出现以下情况,我将如何记录此代码:
- $someGlobalVar 在类的 PHP 文件中不是 decalren(甚至可以不声明)。
- $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 之前使用了以下代码片段:
/**
* 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 中一切似乎都正确,但我不确定这是正确的方法...
任何人都可以确认它没问题吗?
First day I use phpDocumentor and so far so good, but I have a question that I didn't catch in the manual... The documentation of global variables.
How would I document this code if:
- $someGlobalVar is not decalren in the PHP file of the class (it can even be undelared).
- $someGlobalVar is declared like this: $someGlobalVar = array(); (not using the superglobal array like in the phpDocumentor manual).
The PHP code:
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
{
//...
}
}
}
Edit: I want do document these globals as the manual shows but I'm not sure how/where to put the @global and @name tags.
Edit 2: I ended up using the following snippet just before the declaration of getSomeProperty:
/**
* 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.
*/
I use phpDocumentor syntax so that the NetBeans IDE display inline help in the source code. All seems right in NetBeans but I'm not sure it's the way to do...
Anyone can confirm it's OK?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信您会在定义变量的地方记录变量,例如,
当您记录 API 及其功能时,您不需要在类方法中记录它。
无论如何我的意见。
You would document the variable where it is defined I believe, e.g.
You don't need to document it within your class method as you document the API and it's functionality.
My opinion anyway.
由于 $someGlobalVar 是用户定义的,经过一些研究,我认为 @uses 是记录这一点的最合适的方式:
来自文档:
Since $someGlobalVar is user defined and after some research I think @uses is the most suited way to document this:
From the documentation: