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

    BACKGROUND The embodiments relate to guest operating system integrity validation, and more particula ...

  2. HorizontalListView中使用notifyDataSetChanged()和notifyDataSetInvalidated()

    今天在项目中用到了水平ListView控件HorizontalListView,也是我在网上找的个开源HorizontalListView直接在项目中使用.我是把HorizontalListView放 ...

  3. Costura.Fody

    使用Costura.Fody将源DLL合并到目标EXE 本文为原创文章,如转载,请在网页明显位置标明原文名称.作者及网址,谢谢! 一.本文主要是使用Costura.Fody工具将源DLL合并到目标EX ...

  4. Spring-data-redis:特性与实例--转载

    原文地址:http://shift-alt-ctrl.iteye.com/blog/1886831 Spring-data-redis为spring-data模块中对redis的支持部分,简称为“SD ...

  5. 仿招商银行载入loading效果

    在招商银行android手机app中.有例如以下图所看到的的loading载入效果: 实现这个效果还是比較简单,就是自己定义dialog,设置自己想要的布局.然后设置旋转动画. 主要步骤: 1,写布局 ...

  6. thinkphp5最最最最简单的ajax实例

    thinkphp5最最最最简单的ajax实例 一.总结 一句话总结:页面端使用$.get()方法传递ajax请求,服务器端判断是不是ajax请求,是的话接受参数,进行逻辑处理之后向客户端返回值. 1. ...

  7. HZK16应用实例

    在C51中,HZK16汉字库的使用(mydows's Blog转载) 定义如下: unsigned char str[]="我" 个字节长度,内容为"我"的GB ...

  8. 大话Spark(8)-源码之DAGScheduler

    DAGScheduler的主要作用有2个: 一.把job划分成多个Stage(Stage内部并行运行,整个作业按照Stage的顺序依次执行) 二.提交任务 以下分别介绍下DAGScheduler是如何 ...

  9. Altium Designer的pcb上添加文字说明

  10. AE中Shapefile文件添加到SDE数据集

    linder_lee 原文 AE中Shapefile文件添加到SDE数据集(c#) 主要完成用C#,通过AE将本地Shapefile文件导入到SDE的指定数据集下面. 首先说下思路: (1) 通过Op ...