summaryrefslogtreecommitdiff
path: root/classes/handler
diff options
context:
space:
mode:
authorwn_ <[email protected]>2021-11-13 14:05:43 +0000
committerwn_ <[email protected]>2021-11-13 14:05:48 +0000
commit1ec003ce352f5bf1418986d7b96c35e75231ffde (patch)
treeaec9ad492da61fa7d960bad96ad51472efb251df /classes/handler
parent25775bb4075e70aa4fad4620d077d4a0e59bb139 (diff)
Typing IHandler methods, typing Handler_Public, fix type of $feed_id (might be tag).
Diffstat (limited to 'classes/handler')
-rw-r--r--classes/handler/administrative.php2
-rw-r--r--classes/handler/protected.php2
-rwxr-xr-xclasses/handler/public.php40
3 files changed, 24 insertions, 20 deletions
diff --git a/classes/handler/administrative.php b/classes/handler/administrative.php
index f2f5b36ba..533cb3630 100644
--- a/classes/handler/administrative.php
+++ b/classes/handler/administrative.php
@@ -1,6 +1,6 @@
<?php
class Handler_Administrative extends Handler_Protected {
- function before($method) {
+ function before(string $method): bool {
if (parent::before($method)) {
if (($_SESSION["access_level"] ?? 0) >= UserHelper::ACCESS_LEVEL_ADMIN) {
return true;
diff --git a/classes/handler/protected.php b/classes/handler/protected.php
index 8e9e5ca1d..a15fc0956 100644
--- a/classes/handler/protected.php
+++ b/classes/handler/protected.php
@@ -1,7 +1,7 @@
<?php
class Handler_Protected extends Handler {
- function before($method) {
+ function before(string $method): bool {
return parent::before($method) && !empty($_SESSION['uid']);
}
}
diff --git a/classes/handler/public.php b/classes/handler/public.php
index 9a9f7b892..e28bb5fd2 100755
--- a/classes/handler/public.php
+++ b/classes/handler/public.php
@@ -1,10 +1,12 @@
<?php
class Handler_Public extends Handler {
- // $feed may be a tag
+ /**
+ * @param string $feed may be a feed ID or tag
+ */
private function generate_syndicated_feed(int $owner_uid, string $feed, bool $is_cat,
int $limit, int $offset, string $search, string $view_mode = "",
- string $format = 'atom', string $order = "", string $orig_guid = "", string $start_ts = "") {
+ string $format = 'atom', string $order = "", string $orig_guid = "", string $start_ts = ""): void {
$note_style = "background-color : #fff7d5;
border-width : 1px; ".
@@ -52,11 +54,13 @@ class Handler_Public extends Handler {
PluginHost::feed_to_pfeed_id((int)$feed));
if ($handler) {
+ // 'get_headlines' is implemented by the plugin.
+ // @phpstan-ignore-next-line
$qfh_ret = $handler->get_headlines(PluginHost::feed_to_pfeed_id((int)$feed), $params);
} else {
user_error("Failed to find handler for plugin feed ID: $feed", E_USER_ERROR);
- return false;
+ return;
}
} else {
@@ -247,7 +251,7 @@ class Handler_Public extends Handler {
}
}
- function getUnread() {
+ function getUnread(): void {
$login = clean($_REQUEST["login"]);
$fresh = clean($_REQUEST["fresh"]) == "1";
@@ -265,7 +269,7 @@ class Handler_Public extends Handler {
}
}
- function getProfiles() {
+ function getProfiles(): void {
$login = clean($_REQUEST["login"]);
$rv = [];
@@ -288,7 +292,7 @@ class Handler_Public extends Handler {
print json_encode($rv);
}
- function logout() {
+ function logout(): void {
if (validate_csrf($_POST["csrf_token"])) {
UserHelper::logout();
header("Location: index.php");
@@ -298,7 +302,7 @@ class Handler_Public extends Handler {
}
}
- function rss() {
+ function rss(): void {
$feed = clean($_REQUEST["id"]);
$key = clean($_REQUEST["key"]);
$is_cat = clean($_REQUEST["is_cat"] ?? false);
@@ -333,21 +337,21 @@ class Handler_Public extends Handler {
header('HTTP/1.1 403 Forbidden');
}
- function updateTask() {
+ function updateTask(): void {
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK);
}
- function housekeepingTask() {
+ function housekeepingTask(): void {
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_HOUSE_KEEPING);
}
- function globalUpdateFeeds() {
+ function globalUpdateFeeds(): void {
RPC::updaterandomfeed_real();
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK);
}
- function login() {
+ function login(): void {
if (!Config::get(Config::SINGLE_USER_MODE)) {
$login = clean($_POST["login"]);
@@ -403,12 +407,12 @@ class Handler_Public extends Handler {
}
}
- function index() {
+ function index(): void {
header("Content-Type: text/plain");
print Errors::to_json(Errors::E_UNKNOWN_METHOD);
}
- function forgotpass() {
+ function forgotpass(): void {
startup_gettext();
session_start();
@@ -587,7 +591,7 @@ class Handler_Public extends Handler {
print "</html>";
}
- function dbupdate() {
+ function dbupdate(): void {
startup_gettext();
if (!Config::get(Config::SINGLE_USER_MODE) && ($_SESSION["access_level"] ?? 0) < 10) {
@@ -730,7 +734,7 @@ class Handler_Public extends Handler {
<?php
}
- function cached() {
+ function cached(): void {
list ($cache_dir, $filename) = explode("/", $_GET["file"], 2);
// we do not allow files with extensions at the moment
@@ -746,7 +750,7 @@ class Handler_Public extends Handler {
}
}
- private function _make_article_tag_uri($id, $timestamp) {
+ private function _make_article_tag_uri(int $id, string $timestamp): string {
$timestamp = date("Y-m-d", strtotime($timestamp));
@@ -756,7 +760,7 @@ class Handler_Public extends Handler {
// this should be used very carefully because this endpoint is exposed to unauthenticated users
// plugin data is not loaded because there's no user context and owner_uid/session may or may not be available
// in general, don't do anything user-related in here and do not modify $_SESSION
- public function pluginhandler() {
+ public function pluginhandler(): void {
$host = new PluginHost();
$plugin_name = basename(clean($_REQUEST["plugin"]));
@@ -788,7 +792,7 @@ class Handler_Public extends Handler {
}
}
- static function _render_login_form(string $return_to = "") {
+ static function _render_login_form(string $return_to = ""): void {
header('Cache-Control: public');
if ($return_to)