我见过几个PHP文件,其中文档块的开头有一些特殊字符。它以/**#@+ 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';
/**#@-*/
它们用于DocBlock模板(请参阅维基百科)。
我在wordpress配置模板中也遇到了这个问题。
这是一种在进行phpdoc注释时减少在相关项目上维护重复注释的方法。这是phpDocumentor
工具的一个功能,虽然有一些针对phpdoc的规范文档(这些建议没有提到这个功能),但实际上并没有规范。
使用这些开始/结束模式告诉phpDocumentor
将这个phpdoc注释应用于开始和结束标记之间的所有项。
/**#@+
* documentation comment for "stuff"
*/
...multiple of the same thing to document...
/**#@-*/
我能找到的唯一文档是manual.phpdoc.org。
无论出于何种原因,docs.hpdoc.org似乎都没有提及此功能。
2018年10月,ArSeN对答案中链接的wiki页面进行了编辑,删除了大部分复制/粘贴的文档。这是该页面被删除前的历史版本的链接。
https://en.wikipedia.org/w/index.php?title=PHPDoc&oldid=863927054#DocBlock_Templates