php - phpDoc 中是否可以自定义标签?

标签 php phpdoc

phpDoc 支持自定义标签吗?我想使用 @untested 标记尚未测试的代码。如何做到这一点?

最佳答案

物有所值,PSR-5 (截至 2020 年 5 月仍处于草案阶段)允许自定义标签前提是您在它们前面加上项目或组织特定的名称:

In support of annotations, it is allowable to introduce a set of tags designed specifically for an individual application or subset of applications (and thus not covered by this specification).

These tags, or annotations, MUST provide a namespace by either

prefixing the tag name with a PHP-style namespace, or by prefixing the tag name with a single vendor-name followed by a hyphen.

...

Example of a tag name prefixed with a vendor name and hyphen:

@phpdoc-event transformer.transform.pre

因此假设 PSR-5 被接受,您似乎可以做类似@myproject-untested 的事情。即使 PSR-5 被接受,也不能保证 phpDoc 工具将支持定义这些自定义标签的方法。

关于php - phpDoc 中是否可以自定义标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38872487/

相关文章:

php - 如何实现基本的 "Long Polling"?

php - Composer 冲突和 Symfony 3

可变长度参数数组的 PHPDoc

Phpdocumentor 和 Slim 路由器文档

php - 在 SQL SELECT 语句和 PDO 中使用大于或等于 (>=) 和小于或等于 (<=)

php - 初学者难以理解 Composer 和框架

php - 使用ElasticSearch无痛脚本在params数组中检查值是否存在

PhpStorm:有没有办法使用内联 PHPDoc 注释在 return 语句上强制执行类型?

php - 定义不解析的 block

php - Netbeans 和 PHPStorm 中的变量类型提示