Skip to content

Commit e492fea

Browse files
committed
Small fixes
1 parent 8f3dba5 commit e492fea

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

src/DiDom/Document.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace DiDom;
44

55
use DOMDocument;
6-
use DOMElement;
76
use DOMXPath;
87
use InvalidArgumentException;
98
use RuntimeException;
@@ -66,11 +65,11 @@ public function createElement($name, $value = '', $attributes = [])
6665
/**
6766
* Adds new child at the end of the children.
6867
*
69-
* @param \DiDom\Element|\DOMElement|array $nodes The appended child.
68+
* @param \DiDom\Element|\DOMNode|array $nodes The appended child.
7069
*
7170
* @return \DiDom\Document
7271
*
73-
* @throws \InvalidArgumentException if the provided argument is not an instance of \DOMElement or \DiDom\Element
72+
* @throws \InvalidArgumentException if the provided argument is not an instance of \DOMNode or \DiDom\Element
7473
*/
7574
public function appendChild($nodes)
7675
{
@@ -81,8 +80,8 @@ public function appendChild($nodes)
8180
$node = $node->getNode();
8281
}
8382

84-
if (!$node instanceof DOMElement) {
85-
throw new InvalidArgumentException(sprintf('Argument 1 passed to %s must be an instance of %s\Element or DOMElement, %s given', __METHOD__, __NAMESPACE__, (is_object($node) ? get_class($node) : gettype($node))));
83+
if (!$node instanceof \DOMNode) {
84+
throw new InvalidArgumentException(sprintf('Argument 1 passed to %s must be an instance of %s\Element or DOMNode, %s given', __METHOD__, __NAMESPACE__, (is_object($node) ? get_class($node) : gettype($node))));
8685
}
8786

8887
$this->displayErrors(false);

src/DiDom/Element.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ public function __construct($name, $value = '', $attributes = [])
4343
/**
4444
* Adds new child at the end of the children.
4545
*
46-
* @param \DiDom\Element|\DOMElement|array $nodes The appended child.
46+
* @param \DiDom\Element|\DOMNode|array $nodes The appended child.
4747
*
4848
* @return \DiDom\Element
4949
*
50-
* @throws \InvalidArgumentException if the provided argument is not an instance of \DOMElement or \DiDom\Element
50+
* @throws \InvalidArgumentException if the provided argument is not an instance of \DOMNode or \DiDom\Element
5151
*/
5252
public function appendChild($nodes)
5353
{
@@ -58,8 +58,8 @@ public function appendChild($nodes)
5858
$node = $node->getNode();
5959
}
6060

61-
if (!$node instanceof DOMElement) {
62-
throw new InvalidArgumentException(sprintf('Argument 1 passed to %s must be an instance of %s\Element or DOMElement, %s given', __METHOD__, __NAMESPACE__, (is_object($node) ? get_class($node) : gettype($node))));
61+
if (!$node instanceof \DOMNode) {
62+
throw new InvalidArgumentException(sprintf('Argument 1 passed to %s must be an instance of %s\Element or DOMNode, %s given', __METHOD__, __NAMESPACE__, (is_object($node) ? get_class($node) : gettype($node))));
6363
}
6464

6565
libxml_use_internal_errors(true);
@@ -220,12 +220,12 @@ public function innerHtml($options = 0)
220220

221221
foreach ($children as $child)
222222
{
223-
$childrenHtml[] = trim($child->ownerDocument->saveXml($child, $options));
223+
$childrenHtml[] = $child->ownerDocument->saveXml($child, $options);
224224
}
225225

226-
$html = implode(PHP_EOL, $childrenHtml);
226+
$html = implode('', $childrenHtml);
227227

228-
return str_replace('
', '', $html);
228+
return html_entity_decode($html);
229229
}
230230

231231
/**

0 commit comments

Comments
 (0)