1
0
mirror of https://git.tt-rss.org/git/tt-rss.git synced 2025-12-13 06:55:56 +00:00

phpstan: deal with plugins/share

This commit is contained in:
Andrew Dolgov
2021-11-13 19:49:37 +03:00
parent 37827427a2
commit 68d7cf44f9

View File

@@ -1,14 +1,16 @@
<?php <?php
class Share extends Plugin { class Share extends Plugin {
/** @var PluginHost $host */
private $host; private $host;
/** @return array<float|string|null> */
function about() { function about() {
return array(null, return array(null,
"Share article by unique URL", "Share article by unique URL",
"fox"); "fox");
} }
/* @var PluginHost $host */ /** @param PluginHost $host */
function init($host) { function init($host) {
$this->host = $host; $this->host = $host;
@@ -20,18 +22,22 @@ class Share extends Plugin {
return $method == "get"; return $method == "get";
} }
/** @return string */
function get_js() { function get_js() {
return file_get_contents(__DIR__ . "/share.js"); return file_get_contents(__DIR__ . "/share.js");
} }
/** @return string */
function get_css() { function get_css() {
return file_get_contents(__DIR__ . "/share.css"); return file_get_contents(__DIR__ . "/share.css");
} }
/** @return string */
function get_prefs_js() { function get_prefs_js() {
return file_get_contents(__DIR__ . "/share_prefs.js"); return file_get_contents(__DIR__ . "/share_prefs.js");
} }
/** @return void */
function unshare() { function unshare() {
$id = $_REQUEST['id']; $id = $_REQUEST['id'];
@@ -42,6 +48,9 @@ class Share extends Plugin {
print __("Article unshared"); print __("Article unshared");
} }
/** @param int $id
*
* @return void */
function hook_prefs_tab_section($id) { function hook_prefs_tab_section($id) {
if ($id == "prefFeedsPublishedGenerated") { if ($id == "prefFeedsPublishedGenerated") {
?> ?>
@@ -56,6 +65,7 @@ class Share extends Plugin {
} }
} }
/** @return void */
function clearArticleKeys() { function clearArticleKeys() {
$sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET uuid = '' WHERE $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET uuid = '' WHERE
owner_uid = ?"); owner_uid = ?");
@@ -64,6 +74,7 @@ class Share extends Plugin {
print __("Shared URLs cleared."); print __("Shared URLs cleared.");
} }
/** @return void */
function newkey() { function newkey() {
$id = $_REQUEST['id']; $id = $_REQUEST['id'];
$uuid = uniqid_short(); $uuid = uniqid_short();
@@ -75,6 +86,10 @@ class Share extends Plugin {
print json_encode(["link" => $uuid]); print json_encode(["link" => $uuid]);
} }
/**
* @param array<string,mixed> $line
*
* @return string */
function hook_article_button($line) { function hook_article_button($line) {
$icon_class = !empty($line['uuid']) ? "is-shared" : ""; $icon_class = !empty($line['uuid']) ? "is-shared" : "";
@@ -83,6 +98,7 @@ class Share extends Plugin {
title='".__('Share by URL')."'>link</i>"; title='".__('Share by URL')."'>link</i>";
} }
/** @return void */
function get() { function get() {
$uuid = clean($_REQUEST["key"] ?? ""); $uuid = clean($_REQUEST["key"] ?? "");
@@ -107,7 +123,7 @@ class Share extends Plugin {
print "Article not found."; print "Article not found.";
} }
private function format_article($id, $owner_uid) { private function format_article(int $id, int $owner_uid) : void {
$pdo = Db::pdo(); $pdo = Db::pdo();
@@ -231,6 +247,7 @@ class Share extends Plugin {
} }
} }
/** @return void */
function shareDialog() { function shareDialog() {
$id = (int)clean($_REQUEST['id'] ?? 0); $id = (int)clean($_REQUEST['id'] ?? 0);
@@ -276,6 +293,7 @@ class Share extends Plugin {
<?php <?php
} }
/** @return int */
function api_version() { function api_version() {
return 2; return 2;
} }