From f41a5bc752f5c725629063ee0bcdfada947a559d Mon Sep 17 00:00:00 2001 From: thibdrev Date: Mon, 15 Jan 2024 18:54:33 +0100 Subject: [PATCH 1/2] phpstan Function dol_get_first_day() should return int but returns string. Function getWeekNumber() should return int but returns string. --- htdocs/core/lib/date.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 479417cc32f..ed0a2b03ebf 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -579,7 +579,7 @@ function dol_get_first_day($year, $month = 1, $gm = false) if ($year > 9999) { return ''; } - return dol_mktime(0, 0, 0, $month, 1, $year, $gm); + return (int) dol_mktime(0, 0, 0, $month, 1, $year, $gm); } @@ -1170,5 +1170,5 @@ function getWeekNumber($day, $month, $year) { $date = new DateTime($year.'-'.$month.'-'.$day); $week = $date->format("W"); - return $week; + return (int) $week; } From f5e0a9c4115c65de8d7ff84c5ab1cfa8f48998d1 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Mon, 15 Jan 2024 20:56:59 +0100 Subject: [PATCH 2/2] phpstan Function dol_get_first_day() should return int but returns string. Function dol_get_last_day() should return int but returns string. --- htdocs/core/lib/date.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index ed0a2b03ebf..634782d7154 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -572,14 +572,14 @@ function dol_get_next_week($day, $week, $month, $year) * True or 1 or 'gmt' to compare with GMT date. * Example: dol_get_first_day(1970,1,false) will return -3600 with TZ+1, a dol_print_date on it will return 1970-01-01 00:00:00 * Example: dol_get_first_day(1970,1,true) will return 0 whatever is TZ, a dol_print_date on it will return 1970-01-01 00:00:00 - * @return int Date for first day, '' if error + * @return int|string Date as a timestamp, '' if error */ function dol_get_first_day($year, $month = 1, $gm = false) { if ($year > 9999) { return ''; } - return (int) dol_mktime(0, 0, 0, $month, 1, $year, $gm); + return dol_mktime(0, 0, 0, $month, 1, $year, $gm); } @@ -591,7 +591,7 @@ function dol_get_first_day($year, $month = 1, $gm = false) * @param int $month Month * @param mixed $gm False or 0 or 'tzserver' = Return date to compare with server TZ, * True or 1 or 'gmt' to compare with GMT date. - * @return int Date for first day, '' if error + * @return int|string Date as a timestamp, '' if error */ function dol_get_last_day($year, $month = 12, $gm = false) {