From de00a095387499cdb5c8eb9c0ab721d67bd0b3fa Mon Sep 17 00:00:00 2001 From: wn_ Date: Tue, 26 Mar 2024 16:38:05 +0000 Subject: Make implicit nullable parameters explicitly nullable. This is to address a deprecation planned for PHP 8.4. https://wiki.php.net/rfc/deprecate-implicitly-nullable-types --- classes/Counters.php | 18 +++++++++--------- classes/Feeds.php | 2 +- classes/PluginHost.php | 4 ++-- classes/RSSUtils.php | 2 +- classes/Sanitizer.php | 2 +- classes/TimeHelper.php | 4 ++-- classes/UserHelper.php | 4 ++-- include/controls.php | 4 ++-- include/functions.php | 12 ++++++------ 9 files changed, 26 insertions(+), 26 deletions(-) diff --git a/classes/Counters.php b/classes/Counters.php index 948e6ee1d..b3cba162c 100644 --- a/classes/Counters.php +++ b/classes/Counters.php @@ -15,11 +15,11 @@ class Counters { } /** - * @param array $feed_ids - * @param array $label_ids + * @param array|null $feed_ids + * @param array|null $label_ids * @return array> */ - static function get_conditional(array $feed_ids = null, array $label_ids = null): array { + static function get_conditional(?array $feed_ids = null, ?array $label_ids = null): array { return [ ...self::get_global(), ...self::get_virt(), @@ -52,10 +52,10 @@ class Counters { } /** - * @param array $cat_ids + * @param array|null $cat_ids * @return array> */ - private static function get_cats(array $cat_ids = null): array { + private static function get_cats(?array $cat_ids = null): array { $ret = []; /* Labels category */ @@ -141,10 +141,10 @@ class Counters { } /** - * @param array $feed_ids + * @param array|null $feed_ids * @return array> */ - private static function get_feeds(array $feed_ids = null): array { + private static function get_feeds(?array $feed_ids = null): array { $span = Tracer::start(__METHOD__); $ret = []; @@ -300,10 +300,10 @@ class Counters { } /** - * @param array $label_ids + * @param array|null $label_ids * @return array> */ - static function get_labels(array $label_ids = null): array { + static function get_labels(?array $label_ids = null): array { $span = Tracer::start(__METHOD__); $ret = []; diff --git a/classes/Feeds.php b/classes/Feeds.php index 88128cc48..4d4ca3240 100644 --- a/classes/Feeds.php +++ b/classes/Feeds.php @@ -2127,7 +2127,7 @@ class Feeds extends Handler_Protected { $cat->delete(); } - static function _add_cat(string $title, int $owner_uid, int $parent_cat = null, int $order_id = 0): bool { + static function _add_cat(string $title, int $owner_uid, ?int $parent_cat = null, int $order_id = 0): bool { $cat = ORM::for_table('ttrss_feed_categories') ->where('owner_uid', $owner_uid) diff --git a/classes/PluginHost.php b/classes/PluginHost.php index e39273672..2098be4e6 100644 --- a/classes/PluginHost.php +++ b/classes/PluginHost.php @@ -429,7 +429,7 @@ class PluginHost { /** * @param PluginHost::KIND_* $kind */ - function load_all(int $kind, int $owner_uid = null, bool $skip_init = false): void { + function load_all(int $kind, ?int $owner_uid = null, bool $skip_init = false): void { $span = Tracer::start(__METHOD__); $span->setAttribute('func.args', json_encode(func_get_args())); @@ -447,7 +447,7 @@ class PluginHost { /** * @param PluginHost::KIND_* $kind */ - function load(string $classlist, int $kind, int $owner_uid = null, bool $skip_init = false): void { + function load(string $classlist, int $kind, ?int $owner_uid = null, bool $skip_init = false): void { $span = Tracer::start(__METHOD__); $span->setAttribute('func.args', json_encode(func_get_args())); diff --git a/classes/RSSUtils.php b/classes/RSSUtils.php index a2bd36a75..68cbfd26a 100644 --- a/classes/RSSUtils.php +++ b/classes/RSSUtils.php @@ -1511,7 +1511,7 @@ class RSSUtils { * * @return array> An array of filter action arrays with keys "type" and "param" */ - static function get_article_filters(array $filters, string $title, string $content, string $link, string $author, array $tags, array &$matched_rules = null, array &$matched_filters = null): array { + static function get_article_filters(array $filters, string $title, string $content, string $link, string $author, array $tags, ?array &$matched_rules = null, ?array &$matched_filters = null): array { $span = Tracer::start(__METHOD__); $matches = array(); diff --git a/classes/Sanitizer.php b/classes/Sanitizer.php index a7bea9e5f..2a5b031df 100644 --- a/classes/Sanitizer.php +++ b/classes/Sanitizer.php @@ -62,7 +62,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) { $span = OpenTelemetry\API\Trace\Span::getCurrent(); $span->addEvent("Sanitizer::sanitize"); diff --git a/classes/TimeHelper.php b/classes/TimeHelper.php index 453ee0cee..f1c437831 100644 --- a/classes/TimeHelper.php +++ b/classes/TimeHelper.php @@ -1,7 +1,7 @@ $attributes */ - function select_feeds_cats(string $name, int $default_id = null, array $attributes = [], - bool $include_all_cats = true, string $root_id = null, int $nest_level = 0, string $id = ""): string { + function select_feeds_cats(string $name, ?int $default_id = null, array $attributes = [], + bool $include_all_cats = true, ?string $root_id = null, int $nest_level = 0, string $id = ""): string { $ret = ""; diff --git a/include/functions.php b/include/functions.php index b1aaf769b..d7d829f29 100644 --- a/include/functions.php +++ b/include/functions.php @@ -41,7 +41,7 @@ * * @deprecated by Prefs::get() */ - function get_pref(string $pref_name, int $owner_uid = null) { + function get_pref(string $pref_name, ?int $owner_uid = null) { return Prefs::get($pref_name, $owner_uid ? $owner_uid : $_SESSION["uid"], $_SESSION["profile"] ?? null); } @@ -50,7 +50,7 @@ * * @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, $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); } @@ -212,7 +212,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) { return Sanitizer::sanitize($str, $force_remove_images, $owner, $site_url, $highlight_words, $article_id); } @@ -251,17 +251,17 @@ } /** @deprecated by UserHelper::authenticate() */ - function authenticate_user(string $login = null, string $password = null, bool $check_only = false, string $service = null): bool { + function authenticate_user(?string $login = null, ?string $password = null, bool $check_only = false, ?string $service = null): bool { return UserHelper::authenticate($login, $password, $check_only, $service); } /** @deprecated by TimeHelper::smart_date_time() */ - function smart_date_time(int $timestamp, int $tz_offset = 0, int $owner_uid = null, bool $eta_min = false): string { + function smart_date_time(int $timestamp, int $tz_offset = 0, ?int $owner_uid = null, bool $eta_min = false): string { return TimeHelper::smart_date_time($timestamp, $tz_offset, $owner_uid, $eta_min); } /** @deprecated by TimeHelper::make_local_datetime() */ - function make_local_datetime(string $timestamp, bool $long, int $owner_uid = null, bool $no_smart_dt = false, bool $eta_min = false): string { + function make_local_datetime(string $timestamp, bool $long, ?int $owner_uid = null, bool $no_smart_dt = false, bool $eta_min = false): string { return TimeHelper::make_local_datetime($timestamp, $long, $owner_uid, $no_smart_dt, $eta_min); } -- cgit v1.2.3