aboutsummaryrefslogtreecommitdiff
path: root/lib/lib_date.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2023-03-31 08:23:39 +0200
committerGravatar GitHub <noreply@github.com> 2023-03-31 08:23:39 +0200
commit288ed04ccc30b58373576dc3be811aee43e67034 (patch)
tree27f4c571e04d64c97737416dfa2b8d65f481dfd8 /lib/lib_date.php
parentc9d5fe2da12cbc3a071ebf9a518afe2789bb3d61 (diff)
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
Diffstat (limited to 'lib/lib_date.php')
-rw-r--r--lib/lib_date.php12
1 files changed, 6 insertions, 6 deletions
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);