summaryrefslogtreecommitdiff
path: root/classes/userhelper.php
diff options
context:
space:
mode:
authorwn_ <[email protected]>2021-11-11 20:25:13 +0000
committerwn_ <[email protected]>2021-11-11 20:25:13 +0000
commit2e3a9098b9e185f8d88162de3ee5c9c99b2722a6 (patch)
treeb9a4fcc417bffb972aa6dc6dd022aa3e89a252ec /classes/userhelper.php
parentf704d25ab15c5ffd988403d36b90fe76fb72916e (diff)
Address PHPStan warnings in 'classes/userhelper.php'.
Diffstat (limited to 'classes/userhelper.php')
-rw-r--r--classes/userhelper.php34
1 files changed, 18 insertions, 16 deletions
diff --git a/classes/userhelper.php b/classes/userhelper.php
index ea714b76b..c09cabb12 100644
--- a/classes/userhelper.php
+++ b/classes/userhelper.php
@@ -32,7 +32,7 @@ class UserHelper {
/** has administrator permissions */
const ACCESS_LEVEL_ADMIN = 10;
- static function authenticate(string $login = null, string $password = null, bool $check_only = false, string $service = null) {
+ static function authenticate(string $login = null, string $password = null, bool $check_only = false, string $service = null): bool {
if (!Config::get(Config::SINGLE_USER_MODE)) {
$user_id = false;
$auth_module = false;
@@ -99,7 +99,7 @@ class UserHelper {
}
}
- static function load_user_plugins(int $owner_uid, PluginHost $pluginhost = null) {
+ static function load_user_plugins(int $owner_uid, PluginHost $pluginhost = null): void {
if (!$pluginhost) $pluginhost = PluginHost::getInstance();
@@ -114,7 +114,7 @@ class UserHelper {
}
}
- static function login_sequence() {
+ static function login_sequence(): void {
$pdo = Db::pdo();
if (Config::get(Config::SINGLE_USER_MODE)) {
@@ -159,7 +159,7 @@ class UserHelper {
}
}
- static function print_user_stylesheet() {
+ static function print_user_stylesheet(): void {
$value = get_pref(Prefs::USER_STYLESHEET);
if ($value) {
@@ -170,7 +170,7 @@ class UserHelper {
}
- static function get_user_ip() {
+ static function get_user_ip(): ?string {
foreach (["HTTP_X_REAL_IP", "REMOTE_ADDR"] as $hdr) {
if (isset($_SERVER[$hdr]))
return $_SERVER[$hdr];
@@ -179,7 +179,7 @@ class UserHelper {
return null;
}
- static function get_login_by_id(int $id) {
+ static function get_login_by_id(int $id): ?string {
$user = ORM::for_table('ttrss_users')
->find_one($id);
@@ -189,7 +189,7 @@ class UserHelper {
return null;
}
- static function find_user_by_login(string $login) {
+ static function find_user_by_login(string $login): ?int {
$user = ORM::for_table('ttrss_users')
->where('login', $login)
->find_one();
@@ -200,7 +200,7 @@ class UserHelper {
return null;
}
- static function logout() {
+ static function logout(): void {
if (session_status() === PHP_SESSION_ACTIVE)
session_destroy();
@@ -211,11 +211,11 @@ class UserHelper {
session_commit();
}
- static function get_salt() {
+ static function get_salt(): string {
return substr(bin2hex(get_random_bytes(125)), 0, 250);
}
- static function reset_password($uid, $format_output = false, $new_password = "") {
+ static function reset_password(int $uid, bool $format_output = false, string $new_password = ""): void {
$user = ORM::for_table('ttrss_users')->find_one($uid);
$message = "";
@@ -298,7 +298,7 @@ class UserHelper {
}
}
- static function get_otp_secret(int $owner_uid, bool $show_if_enabled = false) {
+ static function get_otp_secret(int $owner_uid, bool $show_if_enabled = false): ?string {
$user = ORM::for_table('ttrss_users')->find_one($owner_uid);
if ($user) {
@@ -333,7 +333,7 @@ class UserHelper {
return null;
}
- static function is_default_password() {
+ static function is_default_password(): bool {
$authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]);
if ($authenticator &&
@@ -345,10 +345,12 @@ class UserHelper {
return false;
}
- static function hash_password(string $pass, string $salt, string $algo = "") {
-
- if (!$algo) $algo = self::HASH_ALGOS[0];
-
+ /**
+ * @param UserHelper::HASH_ALGO_* $algo
+ *
+ * @return false|string False if the password couldn't be hashed, otherwise the hash string.
+ */
+ static function hash_password(string $pass, string $salt, string $algo = self::HASH_ALGOS[0]) {
$pass_hash = "";
switch ($algo) {