Skip to content

Commit 90e17c0

Browse files
committed
v1.2.0
1 parent c191f30 commit 90e17c0

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ v1.2.0 [2015-12-21]
1010
- Added ability configuration of `XMLWriter` via `$config` param to `__construct()`
1111
method.
1212
- Added `libxml` to required section of `composer.json`.
13+
- Small enhancements and fixes.
1314

1415
v1.1.0 [2015-08-27]
1516
-------------------

XmlConstructor.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,15 @@
4848
*/
4949
class XmlConstructor extends XMLWriter
5050
{
51+
/**
52+
* @var boolean Flag of completed preparing.
53+
*/
5154
private $_prepared = false;
55+
/**
56+
* @var boolean Flag of added start document tag.
57+
* @since 1.2.0
58+
*/
59+
private $_startDocument = false;
5260

5361
/**
5462
* Constructor of XML document structure.
@@ -119,7 +127,9 @@ public function toOutput()
119127
protected function preparing()
120128
{
121129
if (!$this->_prepared) {
122-
$this->endDocument();
130+
if ($this->_startDocument) {
131+
$this->endDocument();
132+
}
123133
$this->_prepared = true;
124134
}
125135
return $this;
@@ -166,7 +176,9 @@ protected function configIndentString($string)
166176
protected function configStartDocument($arguments)
167177
{
168178
if (is_array($arguments)) {
169-
call_user_func_array([$this, 'startDocument'], $arguments);
179+
if (call_user_func_array([$this, 'startDocument'], $arguments)) {
180+
$this->_startDocument = true;
181+
}
170182
}
171183
}
172184
}

0 commit comments

Comments
 (0)