summaryrefslogtreecommitdiff
path: root/classes/FeedItem_Common.php
diff options
context:
space:
mode:
authorAndrew Dolgov <fox@fakecake.org>2024-12-16 06:29:28 +0000
committerAndrew Dolgov <fox@fakecake.org>2024-12-16 06:29:28 +0000
commite990a3c00fb630465996a29d60d9acc7687c8979 (patch)
tree6a1071eeb3e1a618ac3fe94bcf8363c6fbbc0bb5 /classes/FeedItem_Common.php
parentd1c0ba5944e225165a5761e3d9a6620d27aca263 (diff)
parent6f8f1b30d508dc3d2c3a067ca7fe2d161963ef5f (diff)
Merge branch 'feature/php-misc' into 'master'
More native typing, use some new PHP stuff See merge request tt-rss/tt-rss!88
Diffstat (limited to 'classes/FeedItem_Common.php')
-rw-r--r--classes/FeedItem_Common.php46
1 files changed, 19 insertions, 27 deletions
diff --git a/classes/FeedItem_Common.php b/classes/FeedItem_Common.php
index 1471dc3e3..5ec958699 100644
--- a/classes/FeedItem_Common.php
+++ b/classes/FeedItem_Common.php
@@ -1,18 +1,13 @@
<?php
abstract class FeedItem_Common extends FeedItem {
- /** @var DOMElement */
- protected $elem;
-
- /** @var DOMDocument */
- protected $doc;
-
- /** @var DOMXPath */
- protected $xpath;
+ protected readonly DOMElement $elem;
+ protected readonly DOMDocument $doc;
+ protected readonly DOMXPath $xpath;
function __construct(DOMElement $elem, DOMDocument $doc, DOMXPath $xpath) {
$this->elem = $elem;
- $this->xpath = $xpath;
$this->doc = $doc;
+ $this->xpath = $xpath;
try {
$source = $elem->getElementsByTagName("source")->item(0);
@@ -98,12 +93,11 @@ abstract class FeedItem_Common extends FeedItem {
foreach ($enclosures as $enclosure) {
$enc = new FeedEnclosure();
-
- $enc->type = clean($enclosure->getAttribute("type"));
- $enc->link = clean($enclosure->getAttribute("url"));
- $enc->length = clean($enclosure->getAttribute("length"));
- $enc->height = clean($enclosure->getAttribute("height"));
- $enc->width = clean($enclosure->getAttribute("width"));
+ $enc->type = clean($enclosure->getAttribute('type'));
+ $enc->link = clean($enclosure->getAttribute('url'));
+ $enc->length = clean($enclosure->getAttribute('length'));
+ $enc->height = clean($enclosure->getAttribute('height'));
+ $enc->width = clean($enclosure->getAttribute('width'));
$medium = clean($enclosure->getAttribute("medium"));
if (!$enc->type && $medium) {
@@ -119,17 +113,16 @@ abstract class FeedItem_Common extends FeedItem {
$enclosures = $this->xpath->query("media:group", $this->elem);
foreach ($enclosures as $enclosure) {
- $enc = new FeedEnclosure();
-
/** @var DOMElement|null */
$content = $this->xpath->query("media:content", $enclosure)->item(0);
if ($content) {
- $enc->type = clean($content->getAttribute("type"));
- $enc->link = clean($content->getAttribute("url"));
- $enc->length = clean($content->getAttribute("length"));
- $enc->height = clean($content->getAttribute("height"));
- $enc->width = clean($content->getAttribute("width"));
+ $enc = new FeedEnclosure();
+ $enc->type = clean($content->getAttribute('type'));
+ $enc->link = clean($content->getAttribute('url'));
+ $enc->length = clean($content->getAttribute('length'));
+ $enc->height = clean($content->getAttribute('height'));
+ $enc->width = clean($content->getAttribute('width'));
$medium = clean($content->getAttribute("medium"));
if (!$enc->type && $medium) {
@@ -152,11 +145,10 @@ abstract class FeedItem_Common extends FeedItem {
foreach ($enclosures as $enclosure) {
$enc = new FeedEnclosure();
-
- $enc->type = "image/generic";
- $enc->link = clean($enclosure->getAttribute("url"));
- $enc->height = clean($enclosure->getAttribute("height"));
- $enc->width = clean($enclosure->getAttribute("width"));
+ $enc->type = 'image/generic';
+ $enc->link = clean($enclosure->getAttribute('url'));
+ $enc->height = clean($enclosure->getAttribute('height'));
+ $enc->width = clean($enclosure->getAttribute('width'));
array_push($encs, $enc);
}