Doxygen 在记录 PHP 时出现奇怪的问题 if

发布于 2024-11-10 17:07:18 字数 1444 浏览 3 评论 0原文

当我尝试记录我的项目时,我遇到了一个奇怪的问题。我有以下代码:

//! 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 生成以下内容: No $action2

正如您所看到的,$action2 丢失了。我检查了我的其他文件之一,发现了同样的问题。 if 语句之后的下一件事永远不会被记录,但之后的事情会被记录。如果我从上面的示例中删除 if 语句,我将获得所有 4 个变量的文档 - $page$actionaction2< /code> 和 action3

我花了很多时间试图了解到底出了什么问题,但没有运气,所以每个建议都受到欢迎。

系统是: Windows XP x64 与 Doxygen 1.7.4。 (我正在使用 Doxygen GUI)

更新 另外,当我的代码中有类似的内容时(请注意 if 语句缺少 else)。当我添加 }else{} 时,它就可以工作了。接下来的$variables 不再记录,但该更新是关于if/else 的。

if in code

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:
No $action2

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.

if in code

Doxygen converts it to thisWrong listing of variables

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

梦初启 2024-11-17 17:07:18

看看这个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.

仙女山的月亮 2024-11-17 17:07:18

我相信这是 doxygen 解析 php 时的一个错误。 2008 年也曾出现过一个类似的问题,但从未得到解决 - https://bugzilla。 gnome.org/show_bug.cgi?id=528815

我敢打赌您的问题是相关的。

我有几个建议:

1)我可能偶然发现了一个解决方法。在块后面添加分号似乎可以使其行为正确。

if ($action) {
  echo 'something 1';
}else{
  echo 'something 2';
};

不过,我不知道这是否会导致 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.

if ($action) {
  echo 'something 1';
}else{
  echo 'something 2';
};

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.

眼中杀气 2024-11-17 17:07:18

仅限 PHP:Doxygen 要求所有
PHP语句(即代码)被包装
在函数/方法中,否则你
可能会遇到解析问题。
来源

您是否使用开源 php 框架?是否可以将代码包装到需要的函数/方法中?

PHP only: Doxygen requires that all
PHP statements (i.e. code) is wrapped
in a functions/methods, otherwise you
may run into parse problems.
Source

Are you using an open source php framework? Is it possible to wrap your code into functions/methods where needed?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文