我开始使用Doxygen来记录我的PHP代码。请参阅以下示例:
namespace MyClasses;
class Order {
/**
* Some Description
*
* @var MyClassesCustomer $customer
*/
protected $customer;
}
@var
命令呈现为MyClasses Customer MyClassesOrder::$customer
类型,而不是正确的MyClassesCustomer MyClassesOrder::$customer
,使命名空间保持不变。有什么办法可以做到这一点吗?将两个反斜杠放在\MyClasses\Customer
也不起作用。
另一方面,@param
似乎适用于命名空间。
我使用的是最新版本 1.8.13。配置几乎是默认的。
如果有人仍然遇到这个问题,那么在doxygen的支持下,这个问题已经"解决"。这是Bugzilla bug_795953(现在在:https://github.com/doxygen/doxygen/issues/5553(。
您所要做的就是(在PHP文件中(创建/自定义doxygen的INPUT_FILTER并包含以下代码:
<?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的命令,因此它不能用于代码中的其他任何内容。因此,将所有"\"更改为"::",将使它理解这是一个命名空间引用。