Doxygen 在记录 PHP 时出现奇怪的问题 if
当我尝试记录我的项目时,我遇到了一个奇怪的问题。我有以下代码:
//! Set default ::$action for called controller. If no action is called, default (index) will be set.
$action = isset($_GET[ 'action']) ? $_GET[ 'action'] : 'index';
if ($action) {
echo 'something 1';
}else{
echo 'something 2';
}
//! Set default ::$action2 for called controller. If no action is called, default (index) will be set.
$action2 = isset($_GET[ 'action']) ? $_GET[ 'action'] : 'index';
//! Set default ::$action3 for called controller. If no action is called, default (index) will be set.
$action3 = isset($_GET[ 'action']) ? $_GET[ 'action'] : 'index';
Doxygen 生成以下内容:
正如您所看到的,$action2 丢失了。我检查了我的其他文件之一,发现了同样的问题。 if
语句之后的下一件事永远不会被记录,但之后的事情会被记录。如果我从上面的示例中删除 if
语句,我将获得所有 4 个变量的文档 - $page
、$action
、action2< /code> 和
action3
。
我花了很多时间试图了解到底出了什么问题,但没有运气,所以每个建议都受到欢迎。
系统是: Windows XP x64 与 Doxygen 1.7.4。 (我正在使用 Doxygen GUI)
更新 另外,当我的代码中有类似的内容时(请注意 if
语句缺少 else
)。当我添加 }else{}
时,它就可以工作了。接下来的$variables
不再记录,但该更新是关于if/else
的。
Doxygen 将其转换为此
I face a strange problem while I'm trying to document a project of mine. I have the following code:
//! Set default ::$action for called controller. If no action is called, default (index) will be set.
$action = isset($_GET[ 'action']) ? $_GET[ 'action'] : 'index';
if ($action) {
echo 'something 1';
}else{
echo 'something 2';
}
//! Set default ::$action2 for called controller. If no action is called, default (index) will be set.
$action2 = isset($_GET[ 'action']) ? $_GET[ 'action'] : 'index';
//! Set default ::$action3 for called controller. If no action is called, default (index) will be set.
$action3 = isset($_GET[ 'action']) ? $_GET[ 'action'] : 'index';
Doxygen generates the following:
As you may see, $action2 is missing. I check one of my other files and saw same problem. Next thing after if
statement is never documented, but the one after that is documented. If I remove the if
statement from above example, I get documentation for all 4 variables - $page
, $action
, action2
and action3
.
I spend enormous time of trying to understand what exactly is wrong, but no luck, so every suggestion is welcomed.
System is:
Windows XP x64 with Doxygen 1.7.4. (I'm using the Doxygen GUI)
UPDATE
Also, when I have something like that in my code (notice the missing else
for the if
statement). When I add the }else{}
however it works. Next $variables
is not documented again, but that update was about the if/else
.
Doxygen converts it to this
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看看这个http://www.doxygen.nl/manual/autolink.html这解释了您在第一个代码片段中看到的奇怪现象。
不幸的是,Doxygen 并没有很好地记录过程 PHP 代码,并且在检查了我自己的 doxygen 生成的所有文档后,我找不到任何函数或方法的任何记录变量,除非它们是定义的类属性。
除此之外,我认为最大的 PHP Doxygen 友好项目是 Drupal,他们的指南是为了充分利用 Doxygen 的评论处理系统而编写的。 http://drupal.org/node/1354
请注意,如果这不是您的答案寻找和/或我完全偏离目标,请立即告诉我,以便我删除此答案。
Check out this http://www.doxygen.nl/manual/autolink.html which explains the weirdness you're seeing with the first code snippet.
Unfortunately Doxygen doesn't do so well documenting procedural PHP code AND after checking all of my own doxygen generated documentation, I can't find any documented variables for any function or method unless they are defined class properties.
Otherwise, I think the largest PHP Doxygen friendly project out there is Drupal, their guidelines were written to use Doxygen's comment processing system to it's fullest. http://drupal.org/node/1354
Note, if this is not the answer you're looking for and or I'm completely off target, please let me know immediately so I can delete this answer.
我相信这是 doxygen 解析 php 时的一个错误。 2008 年也曾出现过一个类似的问题,但从未得到解决 - https://bugzilla。 gnome.org/show_bug.cgi?id=528815
我敢打赌您的问题是相关的。
我有几个建议:
1)我可能偶然发现了一个解决方法。在块后面添加分号似乎可以使其行为正确。
不过,我不知道这是否会导致 doxygen 解析出现其他问题。
2) 我在我的 c++ 项目中使用 doxygen,但在我的 php 项目中使用 phpdoc,因为我用它得到了更好的结果。如果您没有出于政治或实际原因使用 doxygen,您可能会考虑这样做。
I believe it's a bug in doxygen when parsing php. There was a similar issue from 2008 that was worked on but never resolved - https://bugzilla.gnome.org/show_bug.cgi?id=528815
I'm willing to bet that your issue is related.
I have a couple of suggestions:
1) I may have stumbled onto a workaround. Adding a semicolon after the block seems to make it behave correctly.
However, I don't know if this will cause other issues with doxygen's parsing.
2) I use doxygen for my c++ projects, but I use phpdoc for my php projects because I have had better results with it. You might consider doing the same if you're not tied to doxygen for political or practical reasons.
您是否使用开源 php 框架?是否可以将代码包装到需要的函数/方法中?
Are you using an open source php framework? Is it possible to wrap your code into functions/methods where needed?