2010-01-29 66 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