PHPDocumentor 注释规范整理_PHP教程
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 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 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 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제











PyCharm 여러 줄 주석 단축키: 코드 주석을 더욱 편리하게 만들고 특정 코드 예제를 요구합니다. 일상적인 프로그래밍 작업에서 코드 주석은 매우 중요한 부분입니다. 이는 코드의 가독성과 유지 관리성을 향상시킬 뿐만 아니라 다른 개발자가 코드의 의도와 디자인 아이디어를 이해하는 데에도 도움이 됩니다. 그러나 수동으로 코드 주석을 추가하는 것은 시간이 많이 걸리고 지루한 작업인 경우가 많습니다. 코드 주석을 보다 효율적으로 만들기 위해 PyCharm은 여러 줄 주석에 대한 단축키를 제공합니다. PyCharm에서는 Ctrl+/를 사용할 수 있습니다.

Java 코드의 유지 관리성을 최적화하는 방법: 경험 및 조언 소프트웨어 개발 과정에서 유지 관리성이 뛰어난 코드를 작성하는 것이 중요합니다. 유지 관리 가능성은 예상치 못한 문제나 추가 노력 없이 코드를 쉽게 이해하고 수정하고 확장할 수 있음을 의미합니다. Java 개발자에게는 코드 유지 관리성을 최적화하는 방법이 중요한 문제입니다. 이 기사에서는 Java 개발자가 코드의 유지 관리성을 향상시키는 데 도움이 되는 몇 가지 경험과 제안을 공유합니다. 표준화된 명명 규칙을 따르면 코드를 더 쉽게 읽을 수 있습니다.

Go 언어에서는 여러 줄의 주석 문자 "/**/"를 사용하여 여러 줄의 코드에 주석을 달 수 있습니다. 여러 줄 주석(블록 주석이라고도 함)은 "/*"로 시작하고 "*/"로 끝나며 중첩될 수 없습니다. 구문은 "/*comment content...*/"입니다. 일반적으로 패키지 문서에 사용되며 코드 조각 덩어리에 대한 설명이나 주석입니다.

iCloud 키체인을 사용하면 웹사이트나 사용자 이름을 기억하거나 추측하지 않고도 비밀번호를 더 쉽게 관리할 수 있습니다. iCloud 키체인에 있는 앱과 웹 사이트의 기존 비밀번호에 메모를 추가하면 됩니다. 이번 포스팅에서는 iPhone의 iCloud Keychain에 저장한 비밀번호에 메모를 추가하는 방법에 대해 설명하겠습니다. 요구 사항 iCloud 키체인에서 이 새로운 기능을 사용하려면 충족해야 할 몇 가지 요구 사항이 있습니다. iOS 15.4 이상을 실행하는 iPhone iCloud 키체인에 저장된 비밀번호 유효한 Apple ID 유효한 인터넷 연결 저장된 비밀번호에 메모를 추가하는 방법 일부 비밀번호를 iCloud 키체인에 저장해야 한다는 것은 말할 필요도 없습니다.

PyCharm 주석 작업 가이드: 코드 작성 경험 최적화 일상적인 코드 작성에서 주석은 매우 중요한 부분입니다. 좋은 댓글은 코드의 가독성을 향상시킬 뿐만 아니라 다른 개발자가 코드를 더 잘 이해하고 유지 관리하는 데에도 도움이 됩니다. 강력한 Python 통합 개발 환경인 PyCharm은 또한 주석에 풍부한 기능과 도구를 제공하여 코드 작성 경험을 크게 최적화할 수 있습니다. 이 문서에서는 PyCharm에서 주석 작업을 수행하는 방법과 PyCharm의 주석을 활용하는 방법을 소개합니다.

Golang은 비교적 높은 코드 가독성과 단순성을 갖춘 프로그래밍 언어입니다. 그러나 코드를 작성할 때 특정 세부 사항을 설명하거나 코드의 가독성을 높이기 위해 주석을 추가해야 하는 부분이 항상 있습니다. 이번 글에서는 Golang Annotation에 대해 소개하겠습니다.

효율성이 향상되었습니다! PyCharm에서 코드에 빠르게 주석을 추가하는 방법 공유 일상적인 소프트웨어 개발 작업에서는 디버깅이나 조정을 위해 코드의 일부를 주석 처리해야 하는 경우가 많습니다. 주석을 한 줄씩 수동으로 추가하면 의심할 여지 없이 작업량이 증가하고 시간이 소모됩니다. 강력한 Python 통합 개발 환경인 PyCharm은 코드에 빠르게 주석을 추가하는 기능을 제공하여 개발 효율성을 크게 향상시킵니다. 이 문서에서는 PyCharm에서 코드에 빠르게 주석을 추가하는 몇 가지 방법을 공유하고 구체적인 코드 예제를 제공합니다. 하나

PyCharm 주석 아티팩트: 코드 주석을 쉽고 효율적으로 만듭니다. 소개: 코드 주석은 코드 읽기, 공동 개발을 용이하게 하든, 후속 코드 유지 관리 및 디버깅을 용이하게 하든 프로그램 개발에 없어서는 안 될 부분입니다. Python 개발에서 PyCharm 주석 아티팩트는 편리하고 효율적인 코드 주석 경험을 제공합니다. 이 기사에서는 PyCharm 주석 아티팩트의 기능과 사용법을 자세히 소개하고 특정 코드 예제를 통해 이를 보여줍니다. 1. PyCharm 주석 신
