注释标签在代码注释中的做用很是大,可是可能不少同窗在日常开发中会忽略这些标签的做用,因此我这边特意整理一些经常使用的注释标记,经过图文展示形式,但愿能帮助你能更好理解每一个注释标签的做用.php
或许你离漂亮的代码,就差一个标签^_^git
项目工程地址 : https://github.com/yinggaozhen/doc-demo/tree/master/phpgithub
_segmentfault
@deprecated
: 被此标记的函数或者成员方法表示下个版本将会被废弃,告知适用方再也不推荐使用此方法.数组
详细代码演示 : https://github.com/yinggaozhen/doc-demo/tree/master/php/deprecatedsvg
@deprecated [<version>] [<description>]
@deprecated
能够填写一个版本号,版本号的规则同@version
@see
来表示被代替的方法_函数
@inheritdoc
: 文档继承,会继承父类的文档注释.单元测试
详细代码演示 : https://github.com/yinggaozhen/doc-demo/tree/master/php/inheritdoc测试
@inheritDoc
@inheritDoc
会继承父类的全部文档注释.在继承以后能够对指定字段进行重写_this
@internal
: 被此标签标记的内部类/方法,做用范围只能限于当前文件,外部文件不可调用.
详细代码演示 : https://github.com/yinggaozhen/doc-demo/tree/master/php/internal
@internal [description]
此标签一般可以使用在单元测试中,好比在单元测试中定义了一个测试用的类,可对此测试类添加@internal
标签,这样别人在正常逻辑中万一不当心错误引用了测试类,在IDE的帮助下,能够第一时间获得反馈.
_
@link
: 此标签能够引导你到指定的外部跳转连接.
详细代码演示 : https://github.com/yinggaozhen/doc-demo/tree/master/php/link
@link [URI] [<description>]
该标签只有1个跳转选项
@外部跳转连接
: 必须是知足RFC2396的跳转连接,例如http://github.com/yinggaozhen - | @see | @link |
---|---|---|
外部连接 | √ | √ |
内部程序 | √ | X |
_
@see
: 此标签能够引导你到指定的外部跳转连接/内部程序.
详细代码演示 : https://github.com/yinggaozhen/doc-demo/tree/master/php/see
@see [URI | FQSEN] [<description>]
该标签能够有两个跳转选项
@外部跳转连接
: 必须是知足RFC2396的跳转连接,例如http://github.com/yinggaozhen @内部程序连接
: 能够跳转到制定的类/方法/变量,如class::method- | @see | @link |
---|---|---|
外部连接 | √ | √ |
内部程序 | √ | X |
_
@var
: 定义一个数据的类型.
详细代码演示 : https://github.com/yinggaozhen/doc-demo/tree/master/php/var
@var [Type] [$element_name] [<description>]
变量类型 | 说明 |
---|---|
string | 字符串 |
integer/int | number/int类型 |
boolean/bool | false/true |
float/double | number/浮点数 |
object | 对象实例 |
specifiedType | 指定类 |
mixed | 任意类型 |
array/specifiedType[] | 数组,能够指定成指定类型的数组 |
resource | 文件资源类型 |
void | 无返回值 |
null | - |
callable | 可执行的回调函数 |
function | 不必定能执行的方法 |
self/$this | 当前实例 |
实现@var能够有两种使用方法
_
@throws
: 抛出一个异常,告诉调用方须要作好处理异常相关工做.
详细代码演示 : https://github.com/yinggaozhen/doc-demo/tree/master/php/throws
@throws [Type] [<description>]
_
文章篇幅有限,这里列举了一部分标签,更多标签能够经过如下工程地址
项目工程地址 : https://github.com/yinggaozhen/doc-demo/tree/master/php
标签会不按期持续更新,欢迎各位star & fork
您的支持是我更新的最大动力~~