From 50adb559823f935582f3ed308b8d4352c5f216ed Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Wed, 8 Jan 2025 13:26:09 +0100 Subject: Add some missing PHP native types (#7191) * Add some missing PHP native types Replaces https://github.com/FreshRSS/FreshRSS/pull/7184 * Clean some types --- lib/Minz/Error.php | 2 +- lib/Minz/Paginator.php | 8 ++++---- lib/Minz/Request.php | 2 +- lib/Minz/View.php | 2 +- lib/lib_rss.php | 5 ++--- 5 files changed, 9 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/Minz/Error.php b/lib/Minz/Error.php index e95fd346c..e44ec8579 100644 --- a/lib/Minz/Error.php +++ b/lib/Minz/Error.php @@ -52,7 +52,7 @@ class Minz_Error { * @param string|array<'error'|'warning'|'notice',list> $logs logs sorted by category (error, warning, notice) * @return list list of matching logs, without the category, according to environment preferences (production / development) */ - private static function processLogs($logs): array { + private static function processLogs(string|array $logs): array { if (is_string($logs)) { return [$logs]; } diff --git a/lib/Minz/Paginator.php b/lib/Minz/Paginator.php index 7d6892c67..265b0c2cb 100644 --- a/lib/Minz/Paginator.php +++ b/lib/Minz/Paginator.php @@ -64,11 +64,11 @@ class Minz_Paginator { * @param Minz_Model $item l'élément à retrouver * @return int|false la page à laquelle se trouve l’élément, false si non trouvé */ - public function pageByItem($item): int|false { + public function pageByItem(Minz_Model $item): int|false { $i = 0; do { - if ($item == $this->items[$i]) { + if ($item === $this->items[$i]) { return (int)(ceil(($i + 1) / $this->nbItemsPerPage)); } $i++; @@ -82,11 +82,11 @@ class Minz_Paginator { * @param Minz_Model $item the element to search * @return int|false the position of the element, or false if not found */ - public function positionByItem($item): int|false { + public function positionByItem(Minz_Model $item): int|false { $i = 0; do { - if ($item == $this->items[$i]) { + if ($item === $this->items[$i]) { return $i; } $i++; diff --git a/lib/Minz/Request.php b/lib/Minz/Request.php index f441bcabf..3304ad480 100644 --- a/lib/Minz/Request.php +++ b/lib/Minz/Request.php @@ -432,7 +432,7 @@ class Minz_Request { * @param bool $redirect If true, uses an HTTP redirection, and if false (default), performs an internal dispatcher redirection. * @throws Minz_ConfigurationException */ - public static function forward($url = [], bool $redirect = false): void { + public static function forward(array $url = [], bool $redirect = false): void { if (empty(Minz_Request::originalRequest())) { self::$originalRequest = $url; } diff --git a/lib/Minz/View.php b/lib/Minz/View.php index 01e8501b0..65573c7bd 100644 --- a/lib/Minz/View.php +++ b/lib/Minz/View.php @@ -247,7 +247,7 @@ class Minz_View { /** * @param string|array{dark?:string,light?:string,default?:string} $themeColors */ - public static function appendThemeColors($themeColors): void { + public static function appendThemeColors(string|array $themeColors): void { self::$themeColors = $themeColors; } diff --git a/lib/lib_rss.php b/lib/lib_rss.php index c93243eff..2a5bdd02f 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -217,8 +217,7 @@ function escapeToUnicodeAlternative(string $text, bool $extended = true): string return trim(str_replace($problem, $replace, $text)); } -/** @param int|float $n */ -function format_number($n, int $precision = 0): string { +function format_number(int|float $n, int $precision = 0): string { // number_format does not seem to be Unicode-compatible return str_replace(' ', ' ', // Thin non-breaking space number_format((float)$n, $precision, '.', ' ') @@ -274,7 +273,7 @@ function html_only_entity_decode(?string $text): string { * @param array|string $log * @return array|string */ -function sensitive_log($log): array|string { +function sensitive_log(array|string $log): array|string { if (is_array($log)) { foreach ($log as $k => $v) { if (in_array($k, ['api_key', 'Passwd', 'T'], true)) { -- cgit v1.2.3