doxygen icon indicating copy to clipboard operation
doxygen copied to clipboard

Problem with heredoc syntax when creating doc for PHP

Open fpierrat opened this issue 1 month ago • 8 comments

Describe the bug I'm trying Doxygen for the first time. Parsing a folder structure with lots of classes in embedded namespaces, the result looks absolutely GREAT, thanks for this wonderful tool... ... but I saw a class where all methods are missing after a given point in the php file. I finally figured out everything stops after using heredoc syntax for a string.

This bug had already been discussed (and apparently fixed) here: https://github.com/doxygen/doxygen/issues/4526 Either it's a rebirth of a previously fixed bug, or there's a particular context in my code or config(1), I'd be glad to give extra details if needed. (1) I used doxywizard so I supppose there shouldn't be tricky configuration details.

To Reproduce The method containing following string is the last method mentionned in the doc.

echo <<<BLABLA
    This is
    a string
    <<<BLABLA;

Replacing this code with the following suppresses the problem:

echo "
    This is
    a string
    ";

Expected behavior No hangup when heredoc syntax encountered

Version Doxygen 1.15.0 , Windows 11, 64 bit.

fpierrat avatar Oct 31 '25 10:10 fpierrat

To be able to, properly, reproduce the problem:

  • Can you please attach a, small, self contained example (source+configuration file in a, compressed, tar or zip file!) that allows us to reproduce the problem? Please don't add external links as they might not be persistent (also references to GitHub repositories are considered non persistent).

The doxywizard produces a settings file (Doxyfile), this is the file intended above and the file might contain some settings that shine a light on the problem.

A quick look at the code showed me that it looks like you should probably use:

echo <<<BLABLA
    This is
    a string
BLABLA;

So the end BLABLA should start at the beginning of the line.

albert-github avatar Oct 31 '25 11:10 albert-github

Thanks for the quick response.

So the end BLABLA should start at the beginning of the line.

A quick test showed your right, this is how Doxygen is awaiting, BUT this is wrong, this is not how it should be ;-)

Your modified code-sample and my original code-sample do NOT produce the same string. I don't find a documentation of this right now (I'll add it later), but here a quick demonstration:

$tagIndented = <<<EOT
		bla
		bli
		blo
		EOT;

$tagNotIndented = <<<EOT
		bla
		bli
		blo
EOT;


echo "<br><br>With tag indented:<br>" . replaceWhiteSpaces($tagIndented);
echo "<br><br>With tag NOT-indented:<br>" . replaceWhiteSpaces($tagNotIndented);


function replaceWhiteSpaces($str){
	return str_replace([' ',"\t","\r","\n"], ['S','T','R','N'], $str) ;
}

Result:

With tag indented:
blaRNbliRNblo

With tag NOT-indented:
TTblaRNTTbliRNTTblo

Indenting the end-tag allows to indent the whole string definition in the code (better code readability) WITHOUT indenting the string content (no need for my SQL-string or GRAPHQL-string to be indented of 10 tabs on each line, just because my PHP code was indented of 10 tabs at this particular place).

Here a short sample reproducing the case (zip). See missing "b" function where indented heredoc was used.

DoxyTestHeredoc.zip

Image

fpierrat avatar Oct 31 '25 14:10 fpierrat

Here the doc refered above: https://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc

Especially:

Image

fpierrat avatar Oct 31 '25 14:10 fpierrat

Regarding the spaces I've already pushed a proposed patch, pull request #11846

albert-github avatar Oct 31 '25 15:10 albert-github

Woaou! I'm really impressed by your reactivity.

I also just fell on another issue: doxygen seems to choke on default values for method string parameters when single quote is used. Shall I open a new issue?

Minimal test case:

class ParamDefault_StringDoubleQuote {
	function a($str="test"){
		echo "ok";
	}
	
	function b($int){
		echo "ok";
	}
}

class ParamDefault_StringSimpleQuote {
	function a($str='test'){
		echo "KO";
	}
	
	function b($int){
		echo "ok";
	}
}

The second class will NOT be documented (class shown, but with no content).

Image

fpierrat avatar Oct 31 '25 15:10 fpierrat

Yes please create a separate issue for this including (standard request):

  • Can you please attach a, small, self contained example (source+configuration file in a, compressed, tar or zip file!) that allows us to reproduce the problem? Please don't add external links as they might not be persistent (also references to GitHub repositories are considered non persistent).
  • Please also specify the full doxygen version used (doxygen -v).

albert-github avatar Oct 31 '25 15:10 albert-github

Ok, done, thanks. https://github.com/doxygen/doxygen/issues/11847

fpierrat avatar Oct 31 '25 15:10 fpierrat

Code has been integrated in master on GitHub (please don't close the issue as this will be done at the moment of an official release).

albert-github avatar Nov 01 '25 10:11 albert-github