目錄
PHPDocumentor 注释规范整理
你会写注释么?从我写代码开始,这个问题就一直困扰着我,相信也同样困扰着其他同学。以前的写注释总是没有一套行之有效的标准,给维护和协同开发带了许多麻烦,直到最近读到了phpdocumentor的注释标准。
 
下面对phpdocumentor的注释标准进行总结:
首頁 後端開發 php教程 PHPDocumentor 注释规范整理_PHP教程

PHPDocumentor 注释规范整理_PHP教程

Jul 13, 2016 am 10:21 AM
註解

PHPDocumentor 注释规范整理

你会写注释么?从我写代码开始,这个问题就一直困扰着我,相信也同样困扰着其他同学。以前的写注释总是没有一套行之有效的标准,给维护和协同开发带了许多麻烦,直到最近读到了phpdocumentor的注释标准。

 

下面对phpdocumentor的注释标准进行总结:


Type(数据类型):

 

    1. string 字符串类型
    2. integer or int 整型
    3. boolean or bool 布尔类型 true or false
    4. float or double 浮点类型
    5. object 对象
    6. mixed 混合类型 没有指定类型或不确定类型时使用
    7. array 数组
    8. resource 资源类型 (如数据库查询返回)
    9. void 空值(控制器返回值经常使用)
    10. null null类型
    11. callable 回调函数
    12. false or true 只返回true or fasle 时使用
    13. self 自身

       

      Tags(标签):

       

      Tag

      Element

      Description

      api

      Methods

      声明接口

      author

      Any

      作者信息

      category

      File, Class

      将一系列的元素分类在一起

      copyright

      Any

      版权信息

      deprecated

      Any

      声明元素已被弃用,可以在将来的版本中删除

      example

      Any

      示例

      filesource

      File

      文件资源

      global

      Variable

      声明一个全集变量

      ignore

      Any

      忽略当前元素 (phpdocumentor 生成文档时)

      internal

      Any

      声明一个值为整形,或者设置一个应用的默认值为整型

      license

      File, Class

      声明许可类型

      link

      Any

      声明一个和当前元素有关的链接

      method

      Class

      声明当前类那些魔术方法可以被调用

      package

      File, Class

      声明当前元素所属的包

      param

      Method, Function

      声明当前元素的一个参数

      property

      Class

      声明当前类有那些魔术方法可以被调用属性

      property-read

      Class

      声明当前类有那些魔术方法可以读取属性

      property-write

      Class

      声明当前类有那些魔术方法可以设置属性

      return

      Method, Function

      返回值

      see

      Any

      说明当前元素参数引用于其他站点或元素

      since

      Any

      声明当前元素始于于哪个版本

      source

      Any, except File

      展示当前元素的源码

      subpackage

      File, Class

      将当期元素分类

      throws

      Method, Function

      说明当前元素抛出的异常

      todo

      Any

      说明当前元素的开发活动

      uses

      Any

      引用一个关联元素

      var

      Properties

      声明属性

      version

      Any

      版本

       

       

      Example(示例):

       

      // =============================

       

      @api

       

       

      /**
        * This method will not change until a major release.
        *
        * @api
        *
        * @return void
        */
        function showVersion()
        {
           <...>
        }
      登入後複製

      // =============================

      @author

      /**
        * @author My Name
        * @author My Name <my.name@example.com>
        */</my.name@example.com>
      登入後複製

      // =============================

      @category

       /**
        * Page-Level DocBlock
        *
        * @category MyCategory
        * @package  MyPackage
        */
      登入後複製

      // =============================

      @copyright

      /**
        * @copyright 1997-2005 The PHP Group
        */
      登入後複製

      // =============================

      @deprecated

      /**
        * @deprecated
        * @deprecated 1.0.0
        * @deprecated No longer used by internal code and not recommended.
        * @deprecated 1.0.0 No longer used by internal code and not recommended.
        */
       function count()
       {
           <...>
       }
      登入後複製

      // =============================

      @example

      /**
        * @example example1.php Counting in action.
        * @example http://example.com/example2.phps Counting in action by a 3rd party.
        * @example My Own Example.php My counting.
        */
       function count()
       {
           <...>
       }
      登入後複製

      // =============================

      @filesource

      /**
        * @filesource
        */
      登入後複製

      // =============================

      @global phpdocumentor2.0不支持

      // =============================

      @ignore

      if ($ostest) {
           /**
            * This define will either be &#39;Unix&#39; or &#39;Windows&#39;
            */
           define(OS,Unix);
       } else {
           /**
            * @ignore
            */
           define(OS,Windows);
       }
      登入後複製

      // =============================

      @internal

       /**
        * @internal
        *
        * @return integer Indicates the number of items.
        */
       function count()
       {
           <...>
       }
      登入後複製

       /**
        * Counts the number of Foo.
        *
        * {@internal Silently adds one extra Foo to compensate for lack of Foo }}
        *
        * @return integer Indicates the number of items.
        */
       function count()
       {
           <...>
       }
      登入後複製

      // =============================

      @license

      /**
        * @license GPL
        * @license http://opensource.org/licenses/gpl-license.php GNU Public License
        */
      登入後複製

      // =============================

      @link

      /**
        * @link http://example.com/my/bar Documentation of Foo.
        *
        * @return integer Indicates the number of items.
        */
       function count()
       {
           <...>
       }
      登入後複製

      /**
        * This method counts the occurrences of Foo.
        *
        * When no more Foo ({@link http://example.com/my/bar}) are given this
        * function will add one as there must always be one Foo.
        *
        * @return integer Indicates the number of items.
        */
       function count()
       {
           <...>
       }
      登入後複製

      // =============================

      @method

      class Parent
       {
           public function __call()
           {
               <...>
           }
       }
       
       /**
        * @method string getString()
        * @method void setInteger(integer $integer)
        * @method setString(integer $integer)
        */
       class Child extends Parent
       {
           <...>
       }
      登入後複製

      // =============================

      @package

      /**
        * @package PSRDocumentationAPI
        */
      登入後複製

      // =============================

      @param

      /**
        * Counts the number of items in the provided array.
        *
        * @param mixed[] $items Array structure to count the elements of.
        *
        * @return int Returns the number of elements.
        */
       function count(array $items)
       {
           <...>
       }
      登入後複製

      // =============================

      @property

      class Parent
       {
           public function __get()
           {
               <...>
           }
       }
       
       /**
        * @property string $myProperty
        */
       class Child extends Parent
       {
           <...>
       }
      登入後複製

      // =============================

      @property-read

      class Parent
       {
           public function __get()
           {
               <...>
           }
       }
       
       /**
        * @property-read string $myProperty
        */
       class Child extends Parent
       {
           <...>
       }
      登入後複製

      // =============================

      @property-write

       class Parent
       {
           public function __set()
           {
               <...>
           }
       }
       
       /**
        * @property-write string $myProperty
        */
       class Child extends Parent
       {
           <...>
       }
      登入後複製

      // =============================

      @return

      /**
        * @return integer Indicates the number of items.
        */
       function count()
       {
           <...>
       }
      登入後複製

      /**
        * @return string|null The label&#39;s text or null if none provided.
        */
       function getLabel()
       {
           <...>
       }
      登入後複製

      // =============================

      @see

       /**
        * @see http://example.com/my/bar Documentation of Foo.
        * @see MyClass::$items           for the property whose items are counted
        * @see MyClass::setItems()       to set the items for this collection.
        *
        * @return integer Indicates the number of items.
        */
       function count()
       {
           <...>
       }
      登入後複製

      // =============================

      @since

      /**
        * @since 1.0.1 First time this was introduced.
        *
        * @return integer Indicates the number of items.
        */
       function count()
       {
           <...>
       }
      登入後複製

       /**
        * @since 1.0.2 Added the $b argument.
        * @since 1.0.1 Added the $a argument.
        * @since 1.0.0
        *
        * @return void
        */
       function dump($a, $b)
       {
           <...>
       }
      登入後複製

      // =============================

      @source

      /**
        * @source 2 1 Check that ensures lazy counting.
        */
       function count()
       {
           if (null === $this->count) {
               <...>
           }
       }
      登入後複製

      // =============================

      @subpackage

      /**
        * @package PSR
        * @subpackage DocumentationAPI
        */
      登入後複製

      // =============================

      @throws

      /**
        * Counts the number of items in the provided array.
        *
        * @param mixed[] $array Array structure to count the elements of.
        *
        * @throws InvalidArgumentException if the provided argument is not of type
        *     &#39;array&#39;.
        *
        * @return int Returns the number of elements.
        */
       function count($items)
       {
           <...>
       }
      登入後複製

      // =============================

      @todo

       /**
        * Counts the number of items in the provided array.
        *
        * @todo add an array parameter to count
        *
        * @return int Returns the number of elements.
        */
       function count()
       {
           <...>
       }
      登入後複製

      // =============================

      @uses

      /**
        * @uses MyClass::$items to retrieve the count from.
        *
        * @return integer Indicates the number of items.
        */
       function count()
       {
           <...>
       }
      登入後複製

      // =============================

      @var

       class Counter
       {
      /**
        * @var
        */
      public $var;
       }
      登入後複製

      // =============================

      @version

      /**
        * @version 1.0.1
        */
       class Counter
       {
           <...>
       }
      登入後複製

       /**
        * @version GIT: $Id$ In development. Very unstable.
        */
       class NeoCounter
       {
           <...>
       }
      登入後複製

       

       

       

       

       

       

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/857042.htmlTechArticlePHPDocumentor 注释规范整理 你会写注释么?从我写代码开始,这个问题就一直困扰着我,相信也同样困扰着其他同学。以前的写注释总是没有...
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

便捷使用PyCharm快捷鍵實現多行註釋 便捷使用PyCharm快捷鍵實現多行註釋 Jan 27, 2024 am 08:02 AM

PyCharm多行註解快速鍵:讓程式碼註解更便捷,需要具體程式碼範例在日常的程式設計工作中,程式碼註解是非常重要的一部分。它不僅可以提高程式碼的可讀性和可維護性,還能幫助其他開發人員理解程式碼的意圖和設計思路。然而,手動添加程式碼註解往往是一項耗時而繁瑣的工作。為了讓我們的程式碼註解更加高效,PyCharm提供了多行註解的快捷鍵。在PyCharm中,我們可以使用Ctrl+/

如何優化Java程式碼的可維護性:經驗與建議 如何優化Java程式碼的可維護性:經驗與建議 Nov 22, 2023 pm 05:18 PM

如何優化Java程式碼的可維護性:經驗與建議在軟體開發過程中,編寫具有良好可維護性的程式碼是至關重要的。可維護性意味著程式碼能夠被輕鬆理解、修改和擴展,而不會引發意外的問題或額外的工作量。對於Java開發者來說,如何優化程式碼的可維護性是一個重要課題。本文將分享一些經驗和建議,幫助Java開發者提升其程式碼的可維護性。遵循規範的命名規則規範的命名規則能夠使程式碼更易讀,

go語言中怎麼註解多行 go語言中怎麼註解多行 Jan 05, 2023 am 10:59 AM

在go語言中,可以使用多行註解符「/**/」來註解多行程式碼。多行註解(簡稱區塊註解),以「/*」開頭,並以「*/」結尾,且不可以嵌套使用,語法「/*註解內容...*/」;多行註解一般用於包的文檔描述或註解成區塊的程式碼片段。

如何在iPhone上為已儲存的密碼添加註釋 如何在iPhone上為已儲存的密碼添加註釋 Feb 28, 2024 pm 07:41 PM

iCloud鑰匙圈可讓您更方便管理密碼,無需依賴記憶或猜測網站或使用者名稱。您可以透過在iCloud鑰匙圈中為應用程式和網站的現有密碼添加註釋來實現這一點。在這篇文章中,我們將說明如何為您儲存在iPhone上的iCloud鑰匙圈中的密碼新增註解。要求您需要滿足一些要求才能在iCloud鑰匙圈中使用這項新功能。運行iOS15.4或更高版本的iPhone密碼儲存在iCloud鑰匙串中的有效AppleID有效的互聯網連接如何為保存的密碼添加註釋毋庸置疑,您應該在iCloudKeychain中存儲一些密

一文詳解golang中的註釋 一文詳解golang中的註釋 Mar 21, 2023 pm 07:38 PM

Golang是一種程式語言,它有著比較高的程式碼可讀性和簡潔性。然而,在編寫程式碼時,總有一些地方需要添加註解來幫助解釋某些細節或增加程式碼的可讀性。在這篇文章中,我們將介紹一些關於Golang註解的內容。

PyCharm註解操作指南:最佳化程式碼編寫體驗 PyCharm註解操作指南:最佳化程式碼編寫體驗 Feb 21, 2024 pm 06:27 PM

PyCharm註解操作指南:最佳化程式碼編寫體驗在日常的程式碼編寫中,註解是非常重要的一環。良好的註解不僅可以提高程式碼的可讀性,還能幫助其他開發人員更好地理解和維護程式碼。 PyCharm作為一個強大的Python整合開發環境,在註解方面也提供了豐富的功能和工具,可以大幅優化程式碼編寫體驗。本文將介紹如何在PyCharm中進行註釋操作,以及如何利用PyCharm的註釋

分享PyCharm中快速註解程式碼的技巧,提高工作效率 分享PyCharm中快速註解程式碼的技巧,提高工作效率 Jan 04, 2024 pm 12:02 PM

效率提升! PyCharm中快速註解程式碼的方法分享在日常的軟體開發工作中,我們經常需要註解掉一部分程式碼進行偵錯或調整。如果手動逐行添加註釋,這無疑會增加我們的工作量和耗費時間。而PyCharm作為一款強大的Python整合開發環境,提供了快速註解程式碼的功能,大大提升了我們的開發效率。本文將分享一些在PyCharm中快速註解程式碼的方法,並提供具體的程式碼範例。單

提升程式碼註解效率的神奇工具:讓PyCharm成為您的首選 提升程式碼註解效率的神奇工具:讓PyCharm成為您的首選 Jan 05, 2024 pm 04:14 PM

PyCharm註解神器:讓程式碼註解變得輕鬆又有效率導語:程式碼註解是程式開發中不可或缺的一部分,無論是為了方便程式碼閱讀、協作開發,還是為了方便後續的程式碼維護與調試。而在Python開發中,PyCharm註解神器則為我們帶來了便利且有效率的程式碼註解體驗。本文將為大家詳細介紹PyCharm註釋神器的功能和使用方法,並結合具體的程式碼範例進行示範。一、PyCharm註釋神

See all articles