你会写凝视么?从我写代码開始。这个问题就一直困扰着我。相信也相同困扰着其它同学。曾经的写凝视总是没有一套行之有效的标准,给维护和协同开发带了很多麻烦,直到近期读到了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>
    */

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

    @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 'Unix' or 'Windows'
    */
    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 PSR\Documentation\API
    */

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

    @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'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 Documentation\API
    */

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

    @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
    * 'array'.
    *
    * @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
    {
    <...>
    }

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

    phpdocumentor手冊:http://www.phpdoc.org/docs/latest/index.html

    (我有限的英语水平,假设不当翻译,请建议,当然,及时修正)

PHPDocumentor 整理目光规范的更多相关文章

  1. 将Html文档整理为规范XML文档

    有多种方式可以在.NET 平台进行HTML文件解析.数据提取,其中最简单.稳妥的办法是先使用工具将Html文档整理成XML文档,再通过XML Dom模型或XPath灵活地进行数据处理.SGML便是一个 ...

  2. 4、SQL基础整理(规范函数)

    规范函数: 绝对值 select abs(-5) print abs(-5) 表中取绝对值的方法: select code,name,abs(chinese)as yuwen from xueshen ...

  3. PHPDocumentor代码注释规范说明

       PHPDocumentor是一个的用PHP写的道具,对于有规则注释的php程序,它能够快速生成具有相互参照,索引等功能的API文档. 标记 用途 描述 @abstract   抽象类的变量和方法 ...

  4. MySQL命名、设计及使用规范--------来自标点符的《MySQL命名、设计及使用规范》

    原文地址:http://www.biaodianfu.com/mysql-best-practices.html 最近在看MySQL相关的内容,整理如下规范,作为一名刚刚学习MySQL的菜鸟,整理的内 ...

  5. 摘要JSR168 PORLET标准手册汉化整理

    本规范汉化资源搜集整理于网上并由我作了些修改和添加,主要为适应大陆的语辞.用语及其他未译之处. 由于本人于水平有限,如有错误,请各位高手指正:若有高见,希望不吝言辞,同为中国开源作项献. 特此严重感谢 ...

  6. C++路径的整理

    写C++,路径的问题一直都让人很头疼,抽空整理一些方法:也许以后会用到: 1."./" 加不加都一样,就是指当前目录 2."../" 表示当前目录的上级目录,即 ...

  7. MySQL命名、设计及使用规范

    本文转载自MySQL命名.设计及使用规范 导语 最近在看MySQL相关的内容,整理如下规范,作为一名刚刚学习MySQL的菜鸟,整理的内容非常的基础,中间可能涉及到有错误的地方,欢迎批评指正,看到有错误 ...

  8. windows路径操作API函数

    备用,方便查找: PathRemoveArgs     去除路径的参数 PathRemoveBackslash   去除路径最后的反斜杠"\" PathAddBackslash 在 ...

  9. Windows phone 8 学习笔记(4) 应用的启动(转)

    Windows phone 8 的应用除了可以直接从开始菜单以及应用列表中打开外,还可以通过其他的方式打开.照片中心.音乐+视频中心提供扩展支持应用从此启动.另外,我们还可以通过文件关联.URI关联的 ...

随机推荐

  1. 通过wmi获取本地硬件信息的一些疑问。

    通过wmi获取本地硬件信息的一些疑问. http://bbs.csdn.net/topics/391017789 http://blog.csdn.net/xcntime/article/detail ...

  2. js进阶 13-5 jquery队列动画如何实现

    js进阶 13-5 jquery队列动画如何实现 一.总结 一句话总结:同一个jquery对象,直接写多个animate()就好. 1.什么是队列动画? 比如说先左再下,而不是左下一起走 2.怎么实现 ...

  3. C# SocketAsyncEventArgs类

    Namespace:System.Net.Sockets Assemblies:System.Net.Sockets.dll, System.dll, netstandard.dll (Represe ...

  4. python获取序列中最大值

    test =[ [1, 2, 3], [4, 5, 6], [7, 8, 9]]   #这个就可以看做是二维数组了,直接创建print(test)print(test[:][1])           ...

  5. angular 响应式表单(登录实例)

    一.表单验证 1. 只有一个验证规则: this.myGroup = this.fb.group({ email:['hurong.cen@qq.com',Validators.required], ...

  6. HDU 2473 Junk-Mail Filter 并查集删除(FZU 2155盟国)

    http://acm.hdu.edu.cn/showproblem.php?pid=2473 http://acm.fzu.edu.cn/problem.php?pid=2155 题目大意: 编号0~ ...

  7. 算法学习笔记(六) 二叉树和图遍历—深搜 DFS 与广搜 BFS

    图的深搜与广搜 复习下二叉树.图的深搜与广搜. 从图的遍历说起.图的遍历方法有两种:深度优先遍历(Depth First Search), 广度优先遍历(Breadth First Search),其 ...

  8. 5、qq物联开发步骤

    1.QQ物联开发步骤 1)测试环境无需申请上线,即可任意调试.意思是什么呢,它是告诉大家,在调试的时候不要点击上面的提交上线,因为目还在调试此设备,一旦上线,QQ物联官方就会来审核你的设备,导致延长研 ...

  9. [Debug] Chrome Devtools: Elements - Console Integration

    The Element Inspector in Chrome DevTools offers powerful integration with the console - learn how to ...

  10. OAM配置代理手冊

     创建webgate与ohs共享实例,copy文件到ohs实例文件夹. 1)进入webgage部署工具文件夹       Cd  /%webgate_home%/webgate/ohs/tools ...