From b5a22b2aa873f4cda50da840be6919a1db43db1e Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sat, 12 Jul 2025 12:18:45 +0900 Subject: [PATCH] Prepare for array_first() and array_last() becoming available in PHP 8.5 https://wiki.php.net/rfc/array_first_last --- common/functions.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/common/functions.php b/common/functions.php index 72b3e9e5b..7bb4911cf 100644 --- a/common/functions.php +++ b/common/functions.php @@ -56,9 +56,12 @@ function lang(?string $code, $value = null) * @param array $array The input array * @return mixed */ -function array_first(array $array) +if (!function_exists('array_first')) { - return reset($array); + function array_first(array $array) + { + return reset($array); + } } /** @@ -79,9 +82,12 @@ function array_first_key(array $array) * @param array $array The input array * @return mixed */ -function array_last(array $array) +if (!function_exists('array_last')) { - return end($array); + function array_last(array $array) + { + return end($array); + } } /**