PHPDocumentor 注释规范整理
你会写注释么?从我写代码开始,这个问题就一直困扰着我,相信也同样困扰着其他同学。以前的写注释总是没有一套行之有效的标准,给维护和协同开发带了许多麻烦,直到最近读到了phpdocumentor的注释标准。
下面对phpdocumentor的注释标准进行总结:
Type(数据类型):
-
- string 字符串类型
- integer or int 整型
- boolean or bool 布尔类型 true or false
- float or double 浮点类型
- object 对象
- mixed 混合类型 没有指定类型或不确定类型时使用
- array 数组
- resource 资源类型 (如数据库查询返回)
- void 空值(控制器返回值经常使用)
- null null类型
- callable 回调函数
- false or true 只返回true or fasle 时使用
- 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 '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 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 stringnull 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 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 * '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 { <...> }
登录后复制

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

热门话题

“你的组织要求你更改PIN消息”将显示在登录屏幕上。当在使用基于组织的帐户设置的电脑上达到PIN过期限制时,就会发生这种情况,在该电脑上,他们可以控制个人设备。但是,如果您使用个人帐户设置了Windows,则理想情况下不应显示错误消息。虽然情况并非总是如此。大多数遇到错误的用户使用个人帐户报告。为什么我的组织要求我在Windows11上更改我的PIN?可能是您的帐户与组织相关联,您的主要方法应该是验证这一点。联系域管理员会有所帮助!此外,配置错误的本地策略设置或不正确的注册表项也可能导致错误。即

Windows11将清新优雅的设计带到了最前沿;现代界面允许您个性化和更改最精细的细节,例如窗口边框。在本指南中,我们将讨论分步说明,以帮助您在Windows操作系统中创建反映您的风格的环境。如何更改窗口边框设置?按+打开“设置”应用。WindowsI转到个性化,然后单击颜色设置。颜色更改窗口边框设置窗口11“宽度=”643“高度=”500“>找到在标题栏和窗口边框上显示强调色选项,然后切换它旁边的开关。若要在“开始”菜单和任务栏上显示主题色,请打开“在开始”菜单和任务栏上显示主题

默认情况下,Windows11上的标题栏颜色取决于您选择的深色/浅色主题。但是,您可以将其更改为所需的任何颜色。在本指南中,我们将讨论三种方法的分步说明,以更改它并个性化您的桌面体验,使其具有视觉吸引力。是否可以更改活动和非活动窗口的标题栏颜色?是的,您可以使用“设置”应用更改活动窗口的标题栏颜色,也可以使用注册表编辑器更改非活动窗口的标题栏颜色。若要了解这些步骤,请转到下一部分。如何在Windows11中更改标题栏的颜色?1.使用“设置”应用按+打开设置窗口。WindowsI前往“个性化”,然

您是否在Windows安装程序页面上看到“出现问题”以及“OOBELANGUAGE”语句?Windows的安装有时会因此类错误而停止。OOBE表示开箱即用的体验。正如错误提示所表示的那样,这是与OOBE语言选择相关的问题。没有什么可担心的,你可以通过OOBE屏幕本身的漂亮注册表编辑来解决这个问题。快速修复–1.单击OOBE应用底部的“重试”按钮。这将继续进行该过程,而不会再打嗝。2.使用电源按钮强制关闭系统。系统重新启动后,OOBE应继续。3.断开系统与互联网的连接。在脱机模式下完成OOBE的所

任务栏缩略图可能很有趣,但它们也可能分散注意力或烦人。考虑到您将鼠标悬停在该区域的频率,您可能无意中关闭了重要窗口几次。另一个缺点是它使用更多的系统资源,因此,如果您一直在寻找一种提高资源效率的方法,我们将向您展示如何禁用它。不过,如果您的硬件规格可以处理它并且您喜欢预览版,则可以启用它。如何在Windows11中启用任务栏缩略图预览?1.使用“设置”应用点击键并单击设置。Windows单击系统,然后选择关于。点击高级系统设置。导航到“高级”选项卡,然后选择“性能”下的“设置”。在“视觉效果”选

在Windows11上的显示缩放方面,我们都有不同的偏好。有些人喜欢大图标,有些人喜欢小图标。但是,我们都同意拥有正确的缩放比例很重要。字体缩放不良或图像过度缩放可能是工作时真正的生产力杀手,因此您需要知道如何对其进行自定义以充分利用系统功能。自定义缩放的优点:对于难以阅读屏幕上的文本的人来说,这是一个有用的功能。它可以帮助您一次在屏幕上查看更多内容。您可以创建仅适用于某些监视器和应用程序的自定义扩展配置文件。可以帮助提高低端硬件的性能。它使您可以更好地控制屏幕上的内容。如何在Windows11

屏幕亮度是使用现代计算设备不可或缺的一部分,尤其是当您长时间注视屏幕时。它可以帮助您减轻眼睛疲劳,提高易读性,并轻松有效地查看内容。但是,根据您的设置,有时很难管理亮度,尤其是在具有新UI更改的Windows11上。如果您在调整亮度时遇到问题,以下是在Windows11上管理亮度的所有方法。如何在Windows11上更改亮度[10种方式解释]单显示器用户可以使用以下方法在Windows11上调整亮度。这包括使用单个显示器的台式机系统以及笔记本电脑。让我们开始吧。方法1:使用操作中心操作中心是访问

Windows上的激活过程有时会突然转向显示包含此错误代码0xc004f069的错误消息。虽然激活过程已经联机,但一些运行WindowsServer的旧系统可能会遇到此问题。通过这些初步检查,如果这些检查不能帮助您激活系统,请跳转到主要解决方案以解决问题。解决方法–关闭错误消息和激活窗口。然后,重新启动计算机。再次从头开始重试Windows激活过程。修复1–从终端激活从cmd终端激活WindowsServerEdition系统。阶段–1检查Windows服务器版本您必须检查您使用的是哪种类型的W
