代码之家  ›  专栏  ›  技术社区  ›  AlexV

phpdocumentor@global和@name问题

  •  2
  • AlexV  · 技术社区  · 15 年前

    我使用的第一天 phpDocumentor 到目前为止还不错,但我有一个手册中没有提到的问题…全局变量的文档。

    如果出现以下情况,我将如何记录此代码:

    1. $someglobalvar是 类的php文件中的decalren(甚至可以取消标记)。
    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看来不错,但我不确定这是怎么做的…

    有人能确认没问题吗?

    2 回复  |  直到 15 年前
        1
  •  1
  •   Stephen Melrose    15 年前

    您将记录变量的定义,我相信,例如

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

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

    不管怎样,我的意见。

        2
  •  1
  •   AlexV    15 年前

    因为$someglobalvar是用户定义的,经过一些研究,我认为 @uses 最适合的记录方式是:

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

    从文档中:

    @uses标记可用于文档 任何元素(全局变量,include, 页,类,函数,定义,方法, 变量)