From e492feae44321e2f4882f6e9466614732822f008 Mon Sep 17 00:00:00 2001 From: Imangazaliev Date: Wed, 16 Mar 2016 18:21:17 +0300 Subject: [PATCH] Small fixes --- src/DiDom/Document.php | 9 ++++----- src/DiDom/Element.php | 14 +++++++------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/DiDom/Document.php b/src/DiDom/Document.php index 361eec4..954e8da 100644 --- a/src/DiDom/Document.php +++ b/src/DiDom/Document.php @@ -3,7 +3,6 @@ namespace DiDom; use DOMDocument; -use DOMElement; use DOMXPath; use InvalidArgumentException; use RuntimeException; @@ -66,11 +65,11 @@ public function createElement($name, $value = '', $attributes = []) /** * Adds new child at the end of the children. * - * @param \DiDom\Element|\DOMElement|array $nodes The appended child. + * @param \DiDom\Element|\DOMNode|array $nodes The appended child. * * @return \DiDom\Document * - * @throws \InvalidArgumentException if the provided argument is not an instance of \DOMElement or \DiDom\Element + * @throws \InvalidArgumentException if the provided argument is not an instance of \DOMNode or \DiDom\Element */ public function appendChild($nodes) { @@ -81,8 +80,8 @@ public function appendChild($nodes) $node = $node->getNode(); } - if (!$node instanceof DOMElement) { - 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)))); + if (!$node instanceof \DOMNode) { + 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)))); } $this->displayErrors(false); diff --git a/src/DiDom/Element.php b/src/DiDom/Element.php index 44991a7..971d005 100644 --- a/src/DiDom/Element.php +++ b/src/DiDom/Element.php @@ -43,11 +43,11 @@ public function __construct($name, $value = '', $attributes = []) /** * Adds new child at the end of the children. * - * @param \DiDom\Element|\DOMElement|array $nodes The appended child. + * @param \DiDom\Element|\DOMNode|array $nodes The appended child. * * @return \DiDom\Element * - * @throws \InvalidArgumentException if the provided argument is not an instance of \DOMElement or \DiDom\Element + * @throws \InvalidArgumentException if the provided argument is not an instance of \DOMNode or \DiDom\Element */ public function appendChild($nodes) { @@ -58,8 +58,8 @@ public function appendChild($nodes) $node = $node->getNode(); } - if (!$node instanceof DOMElement) { - 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)))); + if (!$node instanceof \DOMNode) { + 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)))); } libxml_use_internal_errors(true); @@ -220,12 +220,12 @@ public function innerHtml($options = 0) foreach ($children as $child) { - $childrenHtml[] = trim($child->ownerDocument->saveXml($child, $options)); + $childrenHtml[] = $child->ownerDocument->saveXml($child, $options); } - $html = implode(PHP_EOL, $childrenHtml); + $html = implode('', $childrenHtml); - return str_replace(' ', '', $html); + return html_entity_decode($html); } /**