1
votes

My PHP/HTML code with doxygen-formatted comments:

<!DOCTYPE html>
<?php
/** \file
* \brief php_doxygen_test.php demontrates that doxygen parses the keyword 'do' as a     variable in at least some cases.
*
* php_doxygen_test.php demontrates that doxygen parses the keyword 'do' as a variable in at least some cases. This
* was discovered for a 'do ... while' loop being used to display the contents of an array.
*/
?>
<html lang="en-us">
<head>
<title>PHP-Doxygen 'do ... while' Test</title>
</head>
<body>
<p>Array displayed via 'do ... while'</p>
<pre>
<?php
$starNames = array("Proxima Centauri", "Arcturus", "Sol", "Fomalhaut", "Deneb", "Rigel", "Zeta Ophiuchi"); /**< An indexed array of star names. */
$i = 0; /**< Counter for use in do ... while test. */
do {
  echo $starNames[$i] . "<br>";
  $i++;
} while ($i < count($starNames));
?>
</pre>
</body>
</html>

The PHP code runs fine. However, when I run doxygen (v1.8.5) on the file, it lists do as a variable in addition to $starNames and $i:

Variables
$starNames = array("Proxima Centauri", "Arcturus", "Sol", "Fomalhaut", "Deneb", "Rigel", "Zeta Ophiuchi")
$i = 0
do

In the Variable Documentation section, do is listed as:

do
Initial value:
{
  echo $starNames[$i] . "<br>"

Adding newlines before the do line or removing the echo line from the do loop does not stop doxygen parsing do as a variable. In my actual code, it is doing this for while and for loops as well. This greatly degrades the value of the documentation for my project!

Is there a way to change my PHP code so that doxygen doesn't do this? Alternately, is there a way to tell doxygen to not document 'do' as a variable?

I'm using:

  • doxygen 1.8.5
  • PHP 5.3.8
  • Apache 2.4.3
  • Windows 7 Home Premium SP1

For doxygen, I am using the 'Optimize for C or PHP output' configuration setting.

I've done numerous searches for this problem and have not found anything, including in doxygen's support archives, doxygen's Known Issues, and Stack Overflow.

1

1 Answers

1
votes

Doxygen expects functions, classes, modules, or namespaces when parsing the code, but not statements at the global level, as in your example.

So you should either wrap these statements in a function, or tell doxygen to ignore them using /** @cond */ .. /** @endcond */.