X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=application%2FUtils.php;h=bcfda65c9ca14cef75aac304396f0512dba500d5;hb=cd2878edeeb1f28356c486c73a12af827b2d9f93;hp=4e97cddae26267f6e3c9b4e8a472c7a56aaf597b;hpb=c266a89d0fbb0d60d2d7df0ec171b7cb022224f6;p=github%2Fshaarli%2FShaarli.git diff --git a/application/Utils.php b/application/Utils.php index 4e97cdda..bcfda65c 100644 --- a/application/Utils.php +++ b/application/Utils.php @@ -91,14 +91,18 @@ function endsWith($haystack, $needle, $case = true) */ function escape($input) { - if (is_bool($input)) { + if (null === $input) { + return null; + } + + if (is_bool($input) || is_int($input) || is_float($input) || $input instanceof DateTimeInterface) { return $input; } if (is_array($input)) { $out = array(); foreach ($input as $key => $value) { - $out[$key] = escape($value); + $out[escape($key)] = escape($value); } return $out; } @@ -294,15 +298,15 @@ function normalize_spaces($string) * Requires php-intl to display international datetimes, * otherwise default format '%c' will be returned. * - * @param DateTime $date to format. - * @param bool $time Displays time if true. - * @param bool $intl Use international format if true. + * @param DateTimeInterface $date to format. + * @param bool $time Displays time if true. + * @param bool $intl Use international format if true. * * @return bool|string Formatted date, or false if the input is invalid. */ function format_date($date, $time = true, $intl = true) { - if (! $date instanceof DateTime) { + if (! $date instanceof DateTimeInterface) { return false; }