2010-01-29 64 views
2

第一天我使用phpDocumentor,迄今为止这么好,但我有一个问题,我没有抓住手册......全局变量的文档。phpDocumentor @global和@name问题

我怎么会记录此代码,如果:

  1. $ someGlobalVar是在类的PHP文件中未 decalren(它甚至可以undelared)。
  2. $ 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中似乎都是正确的,但我不确定这是做什么的...

任何人都可以确认它是否正常?

+0

好吧,**我**将解决这个问题,因为不使用全局变量:)但我不认为这就是你想要的答案。 – 2010-01-29 21:15:57

+0

嘿嘿真的,但在我的情况下,我必须记录做了什么:) – AlexV 2010-01-29 21:26:06

+0

对于任何人在Google搜索时遇到问题,[此线程似乎有一个详细的答案。](http://stackoverflow.com/questions/12163292/phpdoc-does-not-scall-to-recognisation-global-variables-in-output-what-am-i-doing-wr) – Byson 2014-11-24 12:09:37

回答

1

因为$ someGlobalVar由用户定义,经过一番研究,我认为@uses是记录这个最适合的方式:

@uses $someGlobalVar User defined array that bla bla bla. 

从文档:

的@uses标签可用于以文档 任何元素(全局变量,包括, 页,类,函数,定义,方法, 变量)

1

你会记录它被定义的变量,我相信,例如,

/** 
* My var 
* @var array 
*/ 
$someGlobalVar = array(); 

当您记录API及其功能时,无需在类方法中记录它。

无论如何我的看法。

+0

想使用@global和@name作为手册显示... – AlexV 2010-01-30 13:57:08