Handle potentially null link, title, etc. in FeedParser.

This commit is contained in:
wn_ 2021-11-14 16:59:21 +00:00
parent 7988c79bd4
commit f5c881586b
1 changed files with 7 additions and 9 deletions

View File

@ -11,18 +11,18 @@ class FeedParser {
private $libxml_errors = [];
/** @var array<FeedItem> */
private $items;
private $items = [];
/** @var string */
/** @var string|null */
private $link;
/** @var string */
/** @var string|null */
private $title;
/** @var int */
/** @var FeedParser::FEED_*|null */
private $type;
/** @var DOMXPath */
/** @var DOMXPath|null */
private $xpath;
const FEED_RDF = 0;
@ -49,8 +49,6 @@ class FeedParser {
}
}
libxml_clear_errors();
$this->items = array();
}
function init() : void {
@ -208,11 +206,11 @@ class FeedParser {
}
function get_link() : string {
return clean($this->link);
return clean($this->link ?? '');
}
function get_title() : string {
return clean($this->title);
return clean($this->title ?? '');
}
/** @return array<FeedItem> */