Merge branch 'feature/php8-union-types' into 'master'

Use native union types in most places.

See merge request tt-rss/tt-rss!80
This commit is contained in:
Andrew Dolgov
2024-11-24 06:36:58 +00:00
24 changed files with 70 additions and 145 deletions

View File

@@ -120,7 +120,6 @@
}
if ($override) {
/** @var Plugin|IHandler|ICatchall $handler */
$handler = $override;
} else {
$reflection = new ReflectionClass($op);

View File

@@ -655,10 +655,9 @@ class API extends Handler {
}
/**
* @param string|int $feed_id
* @return array{0: array<int, array<string, mixed>>, 1: array<string, mixed>} $headlines, $headlines_header
*/
private static function _api_get_headlines($feed_id, int $limit, int $offset,
private static function _api_get_headlines(int|string $feed_id, int $limit, int $offset,
string $filter, bool $is_cat, bool $show_excerpt, bool $show_content, ?string $view_mode, string $order,
bool $include_attachments, int $since_id, string $search = "", bool $include_nested = false,
bool $sanitize_content = true, bool $force_update = false, int $excerpt_length = 100, ?int $check_first_id = null,

View File

@@ -569,7 +569,7 @@ class Article extends Handler_Protected {
*
* @return array<int, Article::ARTICLE_KIND_*|string>
*/
static function _get_image(array $enclosures, string $content, string $site_url, array $headline) {
static function _get_image(array $enclosures, string $content, string $site_url, array $headline): array {
$article_image = "";
$article_stream = "";
$article_kind = 0;

View File

@@ -16,11 +16,10 @@ abstract class Auth_Base extends Plugin implements IAuthModule {
* Can be used instead of find_user_by_login() by external auth modules
* @param string $login
* @param string|false $password
* @return null|int
* @throws Exception
* @throws PDOException
*/
function auto_create_user(string $login, $password = false) {
function auto_create_user(string $login, false|string $password = false): ?int {
if ($login && Config::get(Config::AUTH_AUTO_CREATE)) {
$user_id = UserHelper::find_user_by_login($login);
@@ -49,11 +48,9 @@ abstract class Auth_Base extends Plugin implements IAuthModule {
/** replaced with UserHelper::find_user_by_login()
* @param string $login
* @return null|int
* @deprecated
*/
function find_user_by_login(string $login) {
function find_user_by_login(string $login): ?int {
return UserHelper::find_user_by_login($login);
}
}

View File

@@ -296,7 +296,7 @@ class Config {
* based on source git tree commit used when creating the package
* @return array<string, mixed>|string
*/
static function get_version(bool $as_string = true) {
static function get_version(bool $as_string = true): array|string {
return self::get_instance()->_get_version($as_string);
}
@@ -314,7 +314,7 @@ class Config {
/**
* @return array<string, mixed>|string
*/
private function _get_version(bool $as_string = true) {
private function _get_version(bool $as_string = true): array|string {
$root_dir = self::get_self_dir();
if (empty($this->version)) {
@@ -423,10 +423,7 @@ class Config {
return self::get_migrations()->get_version();
}
/**
* @return bool|int|string
*/
static function cast_to(string $value, int $type_hint) {
static function cast_to(string $value, int $type_hint): bool|int|string {
switch ($type_hint) {
case self::T_BOOL:
return sql_bool_to_bool($value);
@@ -437,10 +434,7 @@ class Config {
}
}
/**
* @return bool|int|string
*/
private function _get(string $param) {
private function _get(string $param): bool|int|string {
list ($value, $type_hint) = $this->params[$param];
return $this->cast_to($value, $type_hint);
@@ -458,10 +452,7 @@ class Config {
$instance->_add($param, $default, $type_hint);
}
/**
* @return bool|int|string
*/
static function get(string $param) {
static function get(string $param): bool|int|string {
$instance = self::get_instance();
return $instance->_get($param);

View File

@@ -2,17 +2,11 @@
class Db_Prefs {
// this class is a stub for the time being (to be removed)
/**
* @return bool|int|null|string
*/
function read(string $pref_name, ?int $user_id = null, bool $die_on_error = false) {
function read(string $pref_name, ?int $user_id = null, bool $die_on_error = false): bool|int|null|string {
return Prefs::get($pref_name, $user_id ?: $_SESSION['uid'], $_SESSION['profile'] ?? null);
}
/**
* @param mixed $value
*/
function write(string $pref_name, $value, ?int $user_id = null, bool $strip_tags = true): bool {
function write(string $pref_name, mixed $value, ?int $user_id = null, bool $strip_tags = true): bool {
return Prefs::set($pref_name, $value, $user_id ?: $_SESSION['uid'], $_SESSION['profile'] ?? null, $strip_tags);
}
}

View File

@@ -3,7 +3,7 @@ abstract class FeedItem {
abstract function get_id(): string;
/** @return int|false a timestamp on success, false otherwise */
abstract function get_date();
abstract function get_date(): false|int;
abstract function get_link(): string;
abstract function get_title(): string;

View File

@@ -15,7 +15,7 @@ class FeedItem_Atom extends FeedItem_Common {
/**
* @return int|false a timestamp on success, false otherwise
*/
function get_date() {
function get_date(): false|int {
$updated = $this->elem->getElementsByTagName("updated")->item(0);
if ($updated) {

View File

@@ -171,7 +171,7 @@ abstract class FeedItem_Common extends FeedItem {
/**
* @return false|string false on failure, otherwise string contents
*/
function subtree_or_text(DOMElement $node) {
function subtree_or_text(DOMElement $node): false|string {
if ($this->count_children($node) == 0) {
return $node->nodeValue;
} else {

View File

@@ -13,7 +13,7 @@ class FeedItem_RSS extends FeedItem_Common {
/**
* @return int|false a timestamp on success, false otherwise
*/
function get_date() {
function get_date(): false|int {
$pubDate = $this->elem->getElementsByTagName("pubDate")->item(0);
if ($pubDate) {

View File

@@ -53,10 +53,9 @@ class Feeds extends Handler_Protected {
}
/**
* @param string|int $feed
* @return array{0: array<int, int>, 1: int, 2: int, 3: bool, 4: array<string, mixed>} $topmost_article_ids, $headlines_count, $feed, $disable_cache, $reply
*/
private function _format_headlines_list($feed, string $method, string $view_mode, int $limit, bool $cat_view,
private function _format_headlines_list(int|string $feed, string $method, string $view_mode, int $limit, bool $cat_view,
int $offset, string $override_order, bool $include_children, ?int $check_first_id = null,
?bool $skip_first_id_check = false, ? string $order_by = ''): array {
@@ -914,13 +913,9 @@ class Feeds extends Handler_Protected {
/**
* @param int|string $feed feed id or tag name
* @param bool $is_cat
* @param bool $unread_only
* @param null|int $owner_uid
* @return int
* @throws PDOException
*/
static function _get_counters($feed, bool $is_cat = false, bool $unread_only = false, ?int $owner_uid = null): int {
static function _get_counters(int|string $feed, bool $is_cat = false, bool $unread_only = false, ?int $owner_uid = null): int {
$n_feed = (int) $feed;
$need_entries = false;
@@ -1157,7 +1152,7 @@ class Feeds extends Handler_Protected {
/**
* @return false|string false if the icon ID was unrecognized, otherwise, the icon identifier string
*/
static function _get_icon(int $id) {
static function _get_icon(int $id): false|string {
switch ($id) {
case Feeds::FEED_ARCHIVED:
return "archive";
@@ -1183,7 +1178,7 @@ class Feeds extends Handler_Protected {
/**
* @return false|int false if the feed couldn't be found by URL+owner, otherwise the feed ID
*/
static function _find_by_url(string $feed_url, int $owner_uid) {
static function _find_by_url(string $feed_url, int $owner_uid): false|int {
$feed = ORM::for_table('ttrss_feeds')
->where('owner_uid', $owner_uid)
->where('feed_url', $feed_url)
@@ -1201,7 +1196,7 @@ class Feeds extends Handler_Protected {
*
* @return false|int false if the category/feed couldn't be found by title, otherwise its ID
*/
static function _find_by_title(string $title, bool $cat = false, int $owner_uid = 0) {
static function _find_by_title(string $title, bool $cat = false, int $owner_uid = 0): false|int {
if ($cat) {
$res = ORM::for_table('ttrss_feed_categories')
@@ -1222,10 +1217,7 @@ class Feeds extends Handler_Protected {
}
}
/**
* @param string|int $id
*/
static function _get_title($id, bool $cat = false): string {
static function _get_title(int|string $id, bool $cat = false): string {
$pdo = Db::pdo();
if ($cat) {

View File

@@ -197,7 +197,7 @@ class Labels
/**
* @return false|int false if the check for an existing label failed, otherwise the number of rows inserted (1 on success)
*/
static function create(string $caption, ?string $fg_color = '', ?string $bg_color = '', ?int $owner_uid = null) {
static function create(string $caption, ?string $fg_color = '', ?string $bg_color = '', ?int $owner_uid = null): false|int {
if (!$owner_uid) $owner_uid = $_SESSION['uid'];

View File

@@ -6,7 +6,7 @@ class Mailer {
* @param array<string, mixed> $params
* @return bool|int bool if the default mail function handled the request, otherwise an int as described in Mailer#mail()
*/
function mail(array $params) {
function mail(array $params): bool|int {
$to_name = $params["to_name"] ?? "";
$to_address = $params["to_address"];

View File

@@ -8,9 +8,9 @@ class OPML extends Handler_Protected {
}
/**
* @return bool|int|void false if writing the file failed, true if printing succeeded, int if bytes were written to a file, or void if $owner_uid is missing
* @return bool|int|null false if writing the file failed, true if printing succeeded, int if bytes were written to a file, or null if $owner_uid is missing
*/
function export() {
function export(): bool|int|null {
$output_name = sprintf("tt-rss_%s_%s.opml", $_SESSION["name"], date("Y-m-d"));
$include_settings = $_REQUEST["include_settings"] == "1";
$owner_uid = $_SESSION["uid"];
@@ -126,10 +126,10 @@ class OPML extends Handler_Protected {
}
/**
* @return bool|int|void false if writing the file failed, true if printing succeeded, int if bytes were written to a file, or void if $owner_uid is missing
* @return bool|int|null false if writing the file failed, true if printing succeeded, int if bytes were written to a file, or null if $owner_uid is missing
*/
function opml_export(string $filename, int $owner_uid, bool $hide_private_feeds = false, bool $include_settings = true, bool $file_output = false) {
if (!$owner_uid) return;
function opml_export(string $filename, int $owner_uid, bool $hide_private_feeds = false, bool $include_settings = true, bool $file_output = false): bool|int|null {
if (!$owner_uid) return null;
if (!$file_output)
if (!isset($_REQUEST["debug"])) {
@@ -610,10 +610,10 @@ class OPML extends Handler_Protected {
/** $filename is optional; assumes HTTP upload with $_FILES otherwise */
/**
* @return bool|void false on failure, true if successful, void if $owner_uid is missing
* @return bool|null false on failure, true if successful, null if $owner_uid is missing
*/
function opml_import(int $owner_uid, string $filename = "") {
if (!$owner_uid) return;
function opml_import(int $owner_uid, string $filename = ""): ?bool {
if (!$owner_uid) return null;
if (!$filename) {
if ($_FILES['opml_file']['error'] != 0) {

View File

@@ -550,7 +550,7 @@ class PluginHost {
/**
* @return false|Plugin false if the handler couldn't be found, otherwise the Plugin/handler
*/
function lookup_handler(string $handler, string $method) {
function lookup_handler(string $handler, string $method): false|Plugin {
$handler = str_replace("-", "_", strtolower($handler));
$method = strtolower($method);
@@ -579,7 +579,7 @@ class PluginHost {
/**
* @return false|Plugin false if the command couldn't be found, otherwise the registered Plugin
*/
function lookup_command(string $command) {
function lookup_command(string $command): false|Plugin {
$command = "-" . strtolower($command);
if (array_key_exists($command, $this->commands)) {
@@ -730,7 +730,7 @@ class PluginHost {
* @param array<int|string, mixed> $default_value
* @return array<int|string, mixed>
*/
function get_array(Plugin $sender, string $name, array $default_value = []) {
function get_array(Plugin $sender, string $name, array $default_value = []): array {
$tmp = $this->get($sender, $name);
if (!is_array($tmp)) $tmp = $default_value;

View File

@@ -164,10 +164,7 @@ class Prefs {
return isset(self::_DEFAULTS[$pref_name]);
}
/**
* @return bool|int|null|string
*/
static function get_default(string $pref_name) {
static function get_default(string $pref_name): bool|int|null|string {
if (self::is_valid($pref_name))
return self::_DEFAULTS[$pref_name][0];
else
@@ -193,14 +190,14 @@ class Prefs {
/**
* @return array<int, array<string, bool|int|null|string>>
*/
static function get_all(int $owner_uid, ?int $profile_id = null) {
static function get_all(int $owner_uid, ?int $profile_id = null): array {
return self::get_instance()->_get_all($owner_uid, $profile_id);
}
/**
* @return array<int, array<string, bool|int|null|string>>
*/
private function _get_all(int $owner_uid, ?int $profile_id = null) {
private function _get_all(int $owner_uid, ?int $profile_id = null): array {
$rv = [];
$ref = new ReflectionClass(get_class($this));
@@ -247,17 +244,11 @@ class Prefs {
}
}
/**
* @return bool|int|null|string
*/
static function get(string $pref_name, int $owner_uid, ?int $profile_id = null) {
static function get(string $pref_name, int $owner_uid, ?int $profile_id = null): bool|int|null|string {
return self::get_instance()->_get($pref_name, $owner_uid, $profile_id);
}
/**
* @return bool|int|null|string
*/
private function _get(string $pref_name, int $owner_uid, ?int $profile_id) {
private function _get(string $pref_name, int $owner_uid, ?int $profile_id): bool|int|null|string {
if (isset(self::_DEFAULTS[$pref_name])) {
if (!$profile_id || in_array($pref_name, self::_PROFILE_BLACKLIST)) $profile_id = null;
@@ -298,34 +289,22 @@ class Prefs {
return isset($this->cache[$cache_key]);
}
/**
* @return bool|int|null|string
*/
private function _get_cache(string $pref_name, int $owner_uid, ?int $profile_id) {
private function _get_cache(string $pref_name, int $owner_uid, ?int $profile_id): bool|int|null|string {
$cache_key = sprintf("%d/%d/%s", $owner_uid, $profile_id, $pref_name);
return $this->cache[$cache_key] ?? null;
}
/**
* @param bool|int|string $value
*/
private function _set_cache(string $pref_name, $value, int $owner_uid, ?int $profile_id): void {
private function _set_cache(string $pref_name, bool|int|string $value, int $owner_uid, ?int $profile_id): void {
$cache_key = sprintf("%d/%d/%s", $owner_uid, $profile_id, $pref_name);
$this->cache[$cache_key] = $value;
}
/**
* @param bool|int|string $value
*/
static function set(string $pref_name, $value, int $owner_uid, ?int $profile_id, bool $strip_tags = true): bool {
static function set(string $pref_name, bool|int|string $value, int $owner_uid, ?int $profile_id, bool $strip_tags = true): bool {
return self::get_instance()->_set($pref_name, $value, $owner_uid, $profile_id);
}
/**
* @param bool|int|string $value
*/
private function _set(string $pref_name, $value, int $owner_uid, ?int $profile_id, bool $strip_tags = true): bool {
private function _set(string $pref_name, bool|int|string $value, int $owner_uid, ?int $profile_id, bool $strip_tags = true): bool {
if (!$profile_id) $profile_id = null;
if ($profile_id && in_array($pref_name, self::_PROFILE_BLACKLIST))

View File

@@ -1785,10 +1785,7 @@ class RSSUtils {
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_HOUSE_KEEPING);
}
/**
* @return false|string
*/
static function update_favicon(string $site_url, int $feed) {
static function update_favicon(string $site_url, int $feed): false|string {
$favicon_urls = self::get_favicon_urls($site_url);
if (count($favicon_urls) == 0) {
@@ -1983,7 +1980,7 @@ class RSSUtils {
* @access public
* @return false|string The favicon URL string, or false if none was found.
*/
static function get_favicon_url(string $url) {
static function get_favicon_url(string $url): false|string {
$favicon_urls = self::get_favicon_urls($url);

View File

@@ -64,7 +64,7 @@ class Sanitizer {
*
* @return false|string The HTML, or false if an error occurred.
*/
public static function sanitize(string $str, ?bool $force_remove_images = false, ?int $owner = null, ?string $site_url = null, ?array $highlight_words = null, ?int $article_id = null) {
public static function sanitize(string $str, ?bool $force_remove_images = false, ?int $owner = null, ?string $site_url = null, ?array $highlight_words = null, ?int $article_id = null): false|string {
if (!$owner && isset($_SESSION["uid"]))
$owner = $_SESSION["uid"];

View File

@@ -53,12 +53,8 @@ class Sessions implements \SessionHandlerInterface {
return true;
}
/**
* @todo set return type to string|false, and remove ReturnTypeWillChange, when min supported is PHP 8
* @return string|false
*/
#[\ReturnTypeWillChange]
public function read(string $id) {
public function read(string $id): false|string {
$sth = Db::pdo()->prepare('SELECT data FROM ttrss_sessions WHERE id=?');
$sth->execute([$id]);
@@ -95,11 +91,10 @@ class Sessions implements \SessionHandlerInterface {
}
/**
* @todo set return type to int|false, and remove ReturnTypeWillChange, when min supported is PHP 8
* @return int|false the number of deleted sessions on success, or false on failure
*/
#[\ReturnTypeWillChange]
public function gc(int $max_lifetime) {
public function gc(int $max_lifetime): false|int {
$result = Db::pdo()->query('DELETE FROM ttrss_sessions WHERE expire < ' . time());
return $result === false ? false : $result->rowCount();
}

View File

@@ -65,7 +65,7 @@ class UrlHelper {
$rel_url,
string $owner_element = "",
string $owner_attribute = "",
string $content_type = "") {
string $content_type = ""): false|string {
$rel_parts = parse_url($rel_url);
@@ -136,7 +136,7 @@ class UrlHelper {
/** extended filtering involves validation for safe ports and loopback
* @return false|string false if something went wrong, otherwise the URL string
*/
static function validate(string $url, bool $extended_filtering = false) {
static function validate(string $url, bool $extended_filtering = false): false|string {
$url = clean($url);
@@ -198,10 +198,7 @@ class UrlHelper {
return $url;
}
/**
* @return false|string
*/
static function resolve_redirects(string $url, int $timeout) {
static function resolve_redirects(string $url, int $timeout): false|string {
$client = self::get_client();
try {
@@ -230,9 +227,9 @@ class UrlHelper {
*/
// TODO: max_size currently only works for CURL transfers
// TODO: multiple-argument way is deprecated, first parameter is a hash now
public static function fetch($options /* previously: 0: $url , 1: $type = false, 2: $login = false, 3: $pass = false,
public static function fetch(array|string $options /* previously: 0: $url , 1: $type = false, 2: $login = false, 3: $pass = false,
4: $post_query = false, 5: $timeout = false, 6: $timestamp = 0, 7: $useragent = false, 8: $encoding = false,
9: $auth_type = "basic" */) {
9: $auth_type = "basic" */): false|string {
self::$fetch_last_error = "";
self::$fetch_last_error_code = -1;
@@ -455,7 +452,7 @@ class UrlHelper {
/**
* @return false|string false if the provided URL didn't match expected patterns, otherwise the video ID string
*/
public static function url_to_youtube_vid(string $url) {
public static function url_to_youtube_vid(string $url): false|string {
$url = str_replace("youtube.com", "youtube-nocookie.com", $url);
$regexps = [

View File

@@ -370,7 +370,6 @@ class UserHelper {
/**
* @param null|int $owner_uid if null, checks current user via session-specific auth module, if set works on internal database only
* @return bool
* @throws PDOException
* @throws Exception
*/
@@ -383,7 +382,7 @@ class UserHelper {
*
* @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]) {
static function hash_password(string $pass, string $salt, string $algo = self::HASH_ALGOS[0]): false|string {
$pass_hash = "";
switch ($algo) {
@@ -498,7 +497,6 @@ class UserHelper {
/**
* @param null|int $owner_uid if null, checks current user via session-specific auth module, if set works on internal database only
* @param string $password password to compare hash against
* @return bool
*/
static function user_has_password(?int $owner_uid, string $password) : bool {
if ($owner_uid) {

View File

@@ -81,11 +81,10 @@
}
/**
* @param mixed $value
* @param array<int|string, string> $values
* @param array<string, mixed> $attributes
*/
function select_tag(string $name, $value, array $values, array $attributes = [], string $id = ""): string {
function select_tag(string $name, mixed $value, array $values, array $attributes = [], string $id = ""): string {
$attributes_str = attributes_to_string($attributes);
$dojo_type = strpos($attributes_str, "dojoType") === false ? "dojoType='fox.form.Select'" : "";

View File

@@ -33,20 +33,16 @@
}
/**
* @return bool|int|null|string
*
* @deprecated by Prefs::get()
*/
function get_pref(string $pref_name, ?int $owner_uid = null) {
function get_pref(string $pref_name, ?int $owner_uid = null): bool|int|null|string {
return Prefs::get($pref_name, $owner_uid ? $owner_uid : $_SESSION["uid"], $_SESSION["profile"] ?? null);
}
/**
* @param bool|int|string $value
*
* @deprecated by Prefs::set()
*/
function set_pref(string $pref_name, $value, ?int $owner_uid = null, bool $strip_tags = true): bool {
function set_pref(string $pref_name, bool|int|string $value, ?int $owner_uid = null, bool $strip_tags = true): bool {
return Prefs::set($pref_name, $value, $owner_uid ? $owner_uid : $_SESSION["uid"], $_SESSION["profile"] ?? null, $strip_tags);
}
@@ -176,7 +172,7 @@
*
* @return array<string, mixed>|string
*/
function get_version() {
function get_version(): array|string {
return Config::get_version();
}
@@ -197,7 +193,7 @@
* @return int
* @throws PDOException
*/
function getFeedUnread($feed, bool $is_cat = false): int {
function getFeedUnread(int|string $feed, bool $is_cat = false): int {
return Feeds::_get_counters($feed, $is_cat, true, $_SESSION["uid"]);
}
@@ -208,7 +204,7 @@
*
* @return false|string The HTML, or false if an error occurred.
*/
function sanitize(string $str, bool $force_remove_images = false, ?int $owner = null, ?string $site_url = null, ?array $highlight_words = null, ?int $article_id = null) {
function sanitize(string $str, bool $force_remove_images = false, ?int $owner = null, ?string $site_url = null, ?array $highlight_words = null, ?int $article_id = null): false|string {
return Sanitizer::sanitize($str, $force_remove_images, $owner, $site_url, $highlight_words, $article_id);
}
@@ -216,9 +212,9 @@
* @deprecated by UrlHelper::fetch()
*
* @param array<string, bool|int|string>|string $params
* @return bool|string false if something went wrong, otherwise string contents
* @return false|string false if something went wrong, otherwise string contents
*/
function fetch_file_contents($params) {
function fetch_file_contents(array|string $params): false|string {
return UrlHelper::fetch($params);
}
@@ -240,9 +236,9 @@
/**
* @deprecated by UrlHelper::validate()
*
* @return bool|string false if something went wrong, otherwise the URL string
* @return false|string false if something went wrong, otherwise the URL string
*/
function validate_url(string $url) {
function validate_url(string $url): false|string {
return UrlHelper::validate($url);
}
@@ -271,12 +267,8 @@
/**
* This is used for user http parameters unless HTML code is actually needed.
*
* @param mixed $param
*
* @return mixed|null
*/
function clean($param) {
function clean(mixed $param): mixed {
if (is_array($param)) {
return array_map("trim", array_map("strip_tags", $param));
} else if (is_string($param)) {
@@ -351,7 +343,6 @@
/** Convert values accepted by tt-rss as true/false to PHP booleans
* @see https://tt-rss.org/ApiReference/#boolean-values
* @param null|string $s null values are considered false
* @return bool
*/
function sql_bool_to_bool(?string $s): bool {
return $s && ($s !== "f" && $s !== "false"); //no-op for PDO, backwards compat for legacy layer
@@ -443,7 +434,7 @@
/**
* @return false|string The decoded string or false if an error occurred.
*/
function gzdecode(string $string) { // no support for 2nd argument
function gzdecode(string $string): false|string { // no support for 2nd argument
return file_get_contents('compress.zlib://data:who/cares;base64,'.
base64_encode($string));
}
@@ -476,10 +467,7 @@
return null;
}
/**
* @param object|string $class
*/
function implements_interface($class, string $interface): bool {
function implements_interface(object|string $class, string $interface): bool {
$class_implemented_interfaces = class_implements($class);
if ($class_implemented_interfaces) {

View File

@@ -165,7 +165,7 @@ class Auth_Internal extends Auth_Base implements IAuthModule2 {
* @throws PDOException
* @throws Exception
*/
function check_password(int $owner_uid, string $password, string $service = '') {
function check_password(int $owner_uid, string $password, string $service = ''): false|int {
$user = ORM::for_table('ttrss_users')->find_one($owner_uid);
@@ -252,7 +252,7 @@ class Auth_Internal extends Auth_Base implements IAuthModule2 {
* @throws PDOException
* @throws Exception
*/
private function check_app_password(string $login, string $password, string $service) {
private function check_app_password(string $login, string $password, string $service): false|int {
$sth = $this->pdo->prepare("SELECT p.id, p.pwd_hash, u.id AS uid
FROM ttrss_app_passwords p, ttrss_users u
WHERE p.owner_uid = u.id AND LOWER(u.login) = LOWER(?) AND service = ?");