php - Doxygen:@var 使用命名空间

标签 php namespaces doxygen

我开始使用 Doxygen 来记录我的 PHP 代码。请参阅以下示例:

namespace \MyClasses;

class Order {
    /**
     * Some Description
     *
     * @var \MyClasses\Customer $customer
     */
    protected $customer;
}
@var命令呈现为 MyClasses Customer MyClasses\Order::$customer作为类型而不是 \MyClasses\Customer MyClasses\Order::$customer这是正确的,保持命名空间不变。有没有办法实现这一目标?放置两个反斜杠 \\MyClasses\\Customer也不起作用。
@param另一方面似乎适用于命名空间。

我使用的是最新版本 1.8.13。配置几乎是默认的。

最佳答案

如果有人仍然遇到这个问题,那么它已在 doxygen 的支持下“解决”了。这是Bugzilla bug_795953 (现在在: https://github.com/doxygen/doxygen/issues/5553 )。

您所要做的(在 PHP 文件中)就是创建/自定义 INPUT_FILTER对于 doxygen 并包含这段代码:

<?php
// Input
$source = file_get_contents($argv[1]);
// removes preceding '\' or '::' for the use of namespaces.
$regexp = '/ \\\\/';
$replace = ' ';
$source = preg_replace($regexp, $replace, $source);
// adds possibility to use '\' for namespaces
$regexp = '/\\\\/';
$replace = '::';
$source = preg_replace($regexp, $replace, $source);
// Output
echo $source;
?>

如果您使用以“@”(@var、@param 等)开头的所有文档“命令”,则此方法有效。如果你不这样做,你必须对正则表达式做一些调整,让它也像这样工作。

doxygen 不识别命名空间的原因是因为 '\' 键被设置为 doxygen 的命令,所以它不能用于代码中的任何其他内容。因此,将所有 '\' 更改为 '::',将使其了解这是一个命名空间引用。

关于php - Doxygen:@var 使用命名空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45679891/

相关文章:

Clang 不知道 Doxygens retval 标签

web-services - 从soap正文消息中删除出站未使用的命名空间

单独 header 中枚举类的 Doxygen 文档

php - 在特殊目录上禁用一些 php 函数

php - 来自多个表的 MySQL 计数列。按主要 ID 对结果进行分组

namespaces - 为什么 Eclipse CDT 在关闭命名空间大括号后不添加注释?

c# - 将自定义代码放在系统 namespace 中

doxygen - 使用 Doxygen 生成 Markdown 用户文档时如何摆脱空白页面

php - WordPress 从 wp_list_categories 中的最后一项删除 <br/> 分隔符

php - Codeigniter 设置主页(默认 Controller )