From 288ed04ccc30b58373576dc3be811aee43e67034 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Fri, 31 Mar 2023 08:23:39 +0200 Subject: PHPStan level 6 for all PDO and Exception classes (#5239) * PHPStan level 6 for all PDO and Exception classes Contributes to https://github.com/FreshRSS/FreshRSS/issues/4112 * Fix type * Now also our remaining own librairies * Motivation for a few more files * A few more DAO classes * Last interface --- lib/lib_date.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/lib_date.php') diff --git a/lib/lib_date.php b/lib/lib_date.php index cb1f1d1e2..00356927f 100644 --- a/lib/lib_date.php +++ b/lib/lib_date.php @@ -42,13 +42,13 @@ function example($dateInterval) { } */ -function _dateFloor($isoDate) { +function _dateFloor(string $isoDate): string { $x = explode('T', $isoDate, 2); $t = isset($x[1]) ? str_pad($x[1], 6, '0') : '000000'; return str_pad($x[0], 8, '01') . 'T' . $t; } -function _dateCeiling($isoDate) { +function _dateCeiling(string $isoDate): string { $x = explode('T', $isoDate, 2); $t = isset($x[1]) && strlen($x[1]) > 1 ? str_pad($x[1], 6, '59') : '235959'; switch (strlen($x[0])) { @@ -62,11 +62,11 @@ function _dateCeiling($isoDate) { } } -function _noDelimit($isoDate) { +function _noDelimit(?string $isoDate): ?string { return $isoDate === null || $isoDate === '' ? null : str_replace(array('-', ':'), '', $isoDate); //FIXME: Bug with negative time zone } -function _dateRelative($d1, $d2) { +function _dateRelative(?string $d1, ?string $d2): ?string { if ($d2 === null) { return $d1 !== null && $d1[0] !== 'P' ? $d1 : null; } elseif ($d2 !== '' && $d2[0] != 'P' && $d1 !== null && $d1[0] !== 'P') { @@ -81,10 +81,10 @@ function _dateRelative($d1, $d2) { /** * Parameter $dateInterval is a string containing an ISO 8601 time interval. - * Returns an array with the minimum and maximum Unix timestamp of this interval, + * @return array{int|null|false,int|null|false} an array with the minimum and maximum Unix timestamp of this interval, * or null if open interval, or false if error. */ -function parseDateInterval($dateInterval) { +function parseDateInterval(string $dateInterval) { $dateInterval = trim($dateInterval); $dateInterval = str_replace('--', '/', $dateInterval); $dateInterval = strtoupper($dateInterval); -- cgit v1.2.3