diff --git a/src/Reader/Entry/AbstractEntry.php b/src/Reader/Entry/AbstractEntry.php index 449d7ae5..7b006875 100644 --- a/src/Reader/Entry/AbstractEntry.php +++ b/src/Reader/Entry/AbstractEntry.php @@ -122,8 +122,9 @@ public function getEncoding() */ public function saveXml() { - $dom = new DOMDocument('1.0', $this->getEncoding()); - $entry = $dom->importNode($this->getElement(), true); + $dom = new DOMDocument('1.0', $this->getEncoding()); + $deep = version_compare(PHP_VERSION, '7', 'ge') ? 1 : true; + $entry = $dom->importNode($this->getElement(), $deep); $dom->appendChild($entry); return $dom->saveXml(); } @@ -202,8 +203,10 @@ public function __call($method, $args) return call_user_func_array(array($extension, $method), $args); } } - throw new Exception\RuntimeException('Method: ' . $method - . ' does not exist and could not be located on a registered Extension'); + throw new Exception\RuntimeException(sprintf( + 'Method: %s does not exist and could not be located on a registered Extension', + $method + )); } /** diff --git a/src/Reader/Extension/Atom/Entry.php b/src/Reader/Extension/Atom/Entry.php index 68fdafcc..06e94a27 100644 --- a/src/Reader/Extension/Atom/Entry.php +++ b/src/Reader/Extension/Atom/Entry.php @@ -103,20 +103,21 @@ public function getContent() case 'html': case 'text/html': $content = $el->nodeValue; - break; + break; case 'xhtml': $this->getXpath()->registerNamespace('xhtml', 'http://www.w3.org/1999/xhtml'); $xhtml = $this->getXpath()->query( $this->getXpathPrefix() . '/atom:content/xhtml:div' )->item(0); $d = new DOMDocument('1.0', $this->getEncoding()); - $xhtmls = $d->importNode($xhtml, true); + $deep = version_compare(PHP_VERSION, '7', 'ge') ? 1 : true; + $xhtmls = $d->importNode($xhtml, $deep); $d->appendChild($xhtmls); $content = $this->collectXhtml( $d->saveXML(), $d->lookupPrefix('http://www.w3.org/1999/xhtml') ); - break; + break; } } @@ -296,9 +297,12 @@ public function getBaseUrl() return $this->data['baseUrl']; } - $baseUrl = $this->getXpath()->evaluate('string(' - . $this->getXpathPrefix() . '/@xml:base[1]' - . ')'); + $baseUrl = $this->getXpath()->evaluate( + 'string(' + . $this->getXpathPrefix() + . '/@xml:base[1]' + . ')' + ); if (!$baseUrl) { $baseUrl = $this->getXpath()->evaluate('string(//@xml:base[1])'); diff --git a/src/Writer/Renderer/Entry/Atom.php b/src/Writer/Renderer/Entry/Atom.php index 9f3aa740..31b0a9ac 100644 --- a/src/Writer/Renderer/Entry/Atom.php +++ b/src/Writer/Renderer/Entry/Atom.php @@ -265,12 +265,14 @@ protected function _setId(DOMDocument $dom, DOMElement $root) if (!$this->getDataContainer()->getId()) { $this->getDataContainer()->setId( - $this->getDataContainer()->getLink()); + $this->getDataContainer()->getLink() + ); } if (!Uri::factory($this->getDataContainer()->getId())->isValid() && !preg_match( "#^urn:[a-zA-Z0-9][a-zA-Z0-9\-]{1,31}:([a-zA-Z0-9\(\)\+\,\.\:\=\@\;\$\_\!\*\-]|%[0-9a-fA-F]{2})*#", - $this->getDataContainer()->getId()) + $this->getDataContainer()->getId() + ) && !$this->_validateTagUri($this->getDataContainer()->getId()) ) { throw new Writer\Exception\InvalidArgumentException('Atom 1.0 IDs must be a valid URI/IRI'); @@ -289,7 +291,11 @@ protected function _setId(DOMDocument $dom, DOMElement $root) */ protected function _validateTagUri($id) { - if (preg_match('/^tag:(?P.*),(?P\d{4}-?\d{0,2}-?\d{0,2}):(?P.*)(.*:)*$/', $id, $matches)) { + if (preg_match( + '/^tag:(?P.*),(?P\d{4}-?\d{0,2}-?\d{0,2}):(?P.*)(.*:)*$/', + $id, + $matches + )) { $dvalid = false; $date = $matches['date']; $d6 = strtotime($date); @@ -341,7 +347,8 @@ protected function _setContent(DOMDocument $dom, DOMElement $root) $element = $dom->createElement('content'); $element->setAttribute('type', 'xhtml'); $xhtmlElement = $this->_loadXhtml($content); - $xhtml = $dom->importNode($xhtmlElement, true); + $deep = version_compare(PHP_VERSION, '7', 'ge') ? 1 : true; + $xhtml = $dom->importNode($xhtmlElement, $deep); $element->appendChild($xhtml); $root->appendChild($element); } @@ -369,8 +376,11 @@ protected function _loadXhtml($content) "/(<[\/]?)([a-zA-Z]+)/" ), '$1xhtml:$2', $xhtml); $dom = new DOMDocument('1.0', $this->getEncoding()); - $dom->loadXML('' - . $xhtml . ''); + $dom->loadXML( + '' + . $xhtml + . '' + ); return $dom->documentElement; } diff --git a/src/Writer/Renderer/Feed/Atom.php b/src/Writer/Renderer/Feed/Atom.php index 2b33f6a1..939babc0 100644 --- a/src/Writer/Renderer/Feed/Atom.php +++ b/src/Writer/Renderer/Feed/Atom.php @@ -40,7 +40,8 @@ public function render() $this->dom = new DOMDocument('1.0', $this->container->getEncoding()); $this->dom->formatOutput = true; $root = $this->dom->createElementNS( - Writer\Writer::NAMESPACE_ATOM_10, 'feed' + Writer\Writer::NAMESPACE_ATOM_10, + 'feed' ); $this->setRootElement($root); $this->dom->appendChild($root); @@ -76,7 +77,8 @@ public function render() } else { if (!$this->dom->documentElement->hasAttribute('xmlns:at')) { $this->dom->documentElement->setAttribute( - 'xmlns:at', 'http://purl.org/atompub/tombstones/1.0' + 'xmlns:at', + 'http://purl.org/atompub/tombstones/1.0' ); } $renderer = new Renderer\Entry\AtomDeleted($entry); @@ -88,7 +90,8 @@ public function render() $renderer->setRootElement($this->dom->documentElement); $renderer->render(); $element = $renderer->getElement(); - $imported = $this->dom->importNode($element, true); + $deep = version_compare(PHP_VERSION, '7', 'ge') ? 1 : true; + $imported = $this->dom->importNode($element, $deep); $root->appendChild($imported); } return $this; diff --git a/src/Writer/Renderer/Feed/Rss.php b/src/Writer/Renderer/Feed/Rss.php index aff8ae16..be902b8a 100644 --- a/src/Writer/Renderer/Feed/Rss.php +++ b/src/Writer/Renderer/Feed/Rss.php @@ -85,7 +85,8 @@ public function render() $renderer->setRootElement($this->dom->documentElement); $renderer->render(); $element = $renderer->getElement(); - $imported = $this->dom->importNode($element, true); + $deep = version_compare(PHP_VERSION, '7', 'ge') ? 1 : true; + $imported = $this->dom->importNode($element, $deep); $channel->appendChild($imported); } return $this; @@ -195,8 +196,11 @@ protected function _setDateModified(DOMDocument $dom, DOMElement $root) protected function _setGenerator(DOMDocument $dom, DOMElement $root) { if (!$this->getDataContainer()->getGenerator()) { - $this->getDataContainer()->setGenerator('Zend_Feed_Writer', - Version::VERSION, 'http://framework.zend.com'); + $this->getDataContainer()->setGenerator( + 'Zend_Feed_Writer', + Version::VERSION, + 'http://framework.zend.com' + ); } $gdata = $this->getDataContainer()->getGenerator();