Skip to content

Commit

Permalink
php 8.1 - fix deprecated message
Browse files Browse the repository at this point in the history
TypeError: count(): Argument Shardj#1 () must be of type Countable|array, null given

PHP Deprecated:  DOMDocument::__construct(): Passing null to parameter Shardj#2 () of type string is deprecated
  • Loading branch information
hungtrinh committed Nov 12, 2022
1 parent 5f7413f commit e4592b5
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions library/Zend/Feed/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ protected function ensureAppended()
public function saveXml()
{
// Return a complete document including XML prologue.
$doc = new DOMDocument($this->_element->ownerDocument->version,
$this->_element->ownerDocument->actualEncoding);
$doc = new DOMDocument((string) $this->_element->ownerDocument->version,
(string) $this->_element->ownerDocument->actualEncoding);
$doc->appendChild($doc->importNode($this->_element, true));
return $doc->saveXML();
}
Expand Down
2 changes: 1 addition & 1 deletion library/Zend/Feed/Pubsubhubbub/Model/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function hasSubscription($key)
.' of "' . $key . '" must be a non-empty string');
}
$result = $this->_db->find($key);
if (count($result)) {
if (count($result ?? [])) {
return true;
}
return false;
Expand Down
4 changes: 2 additions & 2 deletions library/Zend/Feed/Reader/Entry/Rss.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,15 @@ public function getAuthors()
}
}

if (count($authors) === 0) {
if (count($authors ?? []) === 0) {
$authors = $this->getExtension('Atom')->getAuthors();
} else {
$authors = new Zend_Feed_Reader_Collection_Author(
Zend_Feed_Reader::arrayUnique($authors)
);
}

if (count($authors) === 0) {
if (count($authors ?? []) === 0) {
$authors = null;
}

Expand Down
2 changes: 1 addition & 1 deletion library/Zend/Feed/Reader/Extension/Atom/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public function getContent()
$content = $this->getDescription();
}

$this->_data['content'] = trim($content);
$this->_data['content'] = trim((string) $content);

return $this->_data['content'];
}
Expand Down
4 changes: 2 additions & 2 deletions library/Zend/Feed/Reader/Feed/Rss.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ public function getAuthors()
}
}

if (count($authors) === 0) {
if (count($authors ?? []) === 0) {
$authors = $this->getExtension('Atom')->getAuthors();
} else {
$authors = new Zend_Feed_Reader_Collection_Author(
Zend_Feed_Reader::arrayUnique($authors)
);
}

if (count($authors) === 0) {
if (count($authors ?? []) === 0) {
$authors = null;
}

Expand Down

0 comments on commit e4592b5

Please sign in to comment.