fix even more warnings reported by phpstan

This commit is contained in:
Andrew Dolgov 2021-02-06 17:56:47 +03:00
parent c94f1b6ff8
commit 41fc03287e
4 changed files with 11 additions and 17 deletions

View File

@ -174,7 +174,7 @@ class API extends Handler {
$unread = getFeedUnread($cat_id, true); $unread = getFeedUnread($cat_id, true);
if ($unread || !$unread_only) { if ($unread || !$unread_only) {
array_push($cats, array("id" => (int) $cat_id, array_push($cats, array("id" => $cat_id,
"title" => Feeds::getCategoryTitle($cat_id), "title" => Feeds::getCategoryTitle($cat_id),
"unread" => (int) $unread)); "unread" => (int) $unread));
} }
@ -243,6 +243,7 @@ class API extends Handler {
$field = ""; $field = "";
$set_to = ""; $set_to = "";
$additional_fields = "";
switch ($field_raw) { switch ($field_raw) {
case 0: case 0:
@ -842,14 +843,8 @@ class API extends Handler {
$_REQUEST['mode'] = 2; $_REQUEST['mode'] = 2;
$_REQUEST['force_show_empty'] = $include_empty; $_REQUEST['force_show_empty'] = $include_empty;
if ($pf){ $this->wrap(self::STATUS_OK,
$data = $pf->makefeedtree(); array("categories" => $pf->makefeedtree()));
$this->wrap(self::STATUS_OK, array("categories" => $data));
} else {
$this->wrap(self::STATUS_ERR, array("error" =>
'UNABLE_TO_INSTANTIATE_OBJECT'));
}
} }
// only works for labels or uncategorized for the time being // only works for labels or uncategorized for the time being

View File

@ -197,7 +197,7 @@ class Article extends Handler_Protected {
$sth->execute(array_merge([$score], $ids, [$_SESSION['uid']])); $sth->execute(array_merge([$score], $ids, [$_SESSION['uid']]));
print json_encode(["id" => $ids, "score" => (int)$score]); print json_encode(["id" => $ids, "score" => $score]);
} }
function getScore() { function getScore() {
@ -267,7 +267,7 @@ class Article extends Handler_Protected {
$this->pdo->commit(); $this->pdo->commit();
$tags = self::get_article_tags($id); $tags = self::get_article_tags($id);
$tags_str = $this->format_tags_string($tags, $id); $tags_str = $this->format_tags_string($tags);
$tags_str_full = join(", ", $tags); $tags_str_full = join(", ", $tags);
if (!$tags_str_full) $tags_str_full = __("no tags"); if (!$tags_str_full) $tags_str_full = __("no tags");
@ -419,7 +419,7 @@ class Article extends Handler_Protected {
$retval = $plugin->hook_render_enclosure($entry, $hide_images); $retval = $plugin->hook_render_enclosure($entry, $hide_images);
if ($retval) { if (!empty($retval)) {
$rv .= $retval; $rv .= $retval;
} else { } else {
@ -584,8 +584,6 @@ class Article extends Handler_Protected {
<i class='material-icons'>note</i> <i class='material-icons'>note</i>
<div $onclick class='body'>$note</div> <div $onclick class='body'>$note</div>
</div>"; </div>";
return $str;
} }
static function get_article_enclosures($id) { static function get_article_enclosures($id) {
@ -778,7 +776,7 @@ class Article extends Handler_Protected {
if ($article_image) { if ($article_image) {
$article_image = rewrite_relative_url($site_url, $article_image); $article_image = rewrite_relative_url($site_url, $article_image);
if (!$article_kind && (count($enclosures) > 1 || $elems->length > 1)) if (!$article_kind && (count($enclosures) > 1 || (isset($elems) && $elems->length > 1)))
$article_kind = ARTICLE_KIND_ALBUM; $article_kind = ARTICLE_KIND_ALBUM;
} }

View File

@ -40,7 +40,7 @@ class Backend extends Handler_Protected {
foreach ($hotkeys as $action => $description) { foreach ($hotkeys as $action => $description) {
if (is_array($omap[$action])) { if (!empty($omap[$action])) {
foreach ($omap[$action] as $sequence) { foreach ($omap[$action] as $sequence) {
if (strpos($sequence, "|") !== false) { if (strpos($sequence, "|") !== false) {
$sequence = substr($sequence, $sequence = substr($sequence,

View File

@ -120,7 +120,8 @@ class Counters {
$has_img = false; $has_img = false;
} }
if (date('Y') - date('Y', strtotime($line['last_updated'])) > 2) // hide default un-updated timestamp i.e. 1980-01-01 (?) -fox
if ((int)date('Y') - (int)date('Y', strtotime($line['last_updated'])) > 2)
$last_updated = ''; $last_updated = '';
$cv = [ $cv = [