docblox/docblox — Issue #351: Generating documentation fails if default values for properties contain Special Chars/HTML Code
Author: ThorstenSuckow
Created: 2012-01-10 15:33:26+00:00
State: open

Assume you have the following code:

class Test {

public $test = "News & other stuff";

}

This will generate the following XML in structure.xml:

$test
"News

- the parser fails with the following output:

PHP Warning: DOMElement::__construct(): unterminated entity reference other stuff" in /src/DocBlox/Parser/Exporter/Xml/Variable.php on line 3
8

Reason is, that DOMElement seems to take care of encoding when it should not. See DocBlox_Parser_Exporter_Xml_Variable line 38

Proposed fix:
Do not use DOMElement, but create a CDATA Section for default values instead:

Replace Line 38 in DocBlox_Parser_Exporter_Xml_Variable with:

-$child->appendChild(new DOMElement('default', $variable->getDefault()));
+$m = $child->appendChild(new DomElement('default'));
+$m->appendChild(new DOMCdataSection(($variable->getDefault())));