在PHP注释块中,#@+和#@-代表什么意思?

3
我看到过一些PHP文件,在doc块的开头有一些特殊字符。 它以/**#@+ some doc-text */开始,以/**#@-*/结束。
这些符号代表什么意思?
我发现这似乎在各种PHP框架(Zend、phpseclib、Magento)中使用,但找不到解释。
例如:
/**#@+
 * Constants for keys of data array. Identical to the name of the getter in snake case
 */
const ID = 'id';
const CUSTOMER_ID = 'customer_id';
const REGION = 'region';
const REGION_ID = 'region_id';
const COUNTRY_ID = 'country_id';
const STREET = 'street';
const COMPANY = 'company';
const TELEPHONE = 'telephone';
const FAX = 'fax';
const POSTCODE = 'postcode';
const CITY = 'city';
const FIRSTNAME = 'firstname';
const LASTNAME = 'lastname';
const MIDDLENAME = 'middlename';
const PREFIX = 'prefix';
const SUFFIX = 'suffix';
const VAT_ID = 'vat_id';
const DEFAULT_BILLING = 'default_billing';
const DEFAULT_SHIPPING = 'default_shipping';
/**#@-*/
2个回答


0

我在wordpress配置模板中也遇到了这个问题。

这是一种减少在编写phpdoc注释时相关项目上维护重复注释的方法。这是phpDocumentor工具的一个功能,虽然没有真正的规范,但有一些关于phpdoc的提议规范文件(这些提议并未提到此功能)。

使用这些起始/结束模式告诉phpDocumentor将此phpdoc注释应用于起始和结束标记之间的所有项目。

/**#@+
 * documentation comment for "stuff"
 */
...multiple of the same thing to document...

/**#@-*/

我能找到的唯一文档是在manual.phpdoc.org
docs.phpdoc.org似乎没有任何关于这个功能的参考,原因不明。
ArSeN的答案中链接的维基页面在2018年10月被编辑以删除大部分复制粘贴的文档。这是页面被删除之前的历史版本链接。

https://en.wikipedia.org/w/index.php?title=PHPDoc&oldid=863927054#DocBlock_Templates


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接