From 627b21b4306f0c3698f9e8e94dfcce22022a8d4b Mon Sep 17 00:00:00 2001 From: bilel gasmi Date: Tue, 5 Jan 2021 22:26:14 +0100 Subject: [PATCH] [WIP] Add several functions - current - next - prev - end - reset --- generated/array.php | 105 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/generated/array.php b/generated/array.php index 80c90ff8..eef5d79e 100644 --- a/generated/array.php +++ b/generated/array.php @@ -462,3 +462,108 @@ function usort(array &$array, callable $value_compare_func): void throw ArrayException::createFromPhpError(); } } + + +/** + * This function will return the current element in an array. + * + * @param object|array $array The input array. + * + * @return mixed + * @throws ArrayException + * + */ +function current($array) +{ + error_clear_last(); + $result = \current($array); + if ($result === false) { + throw ArrayException::createFromPhpError(); + } + + return $result; +} + + +/** + * This function will set the internal pointer of an array to its last element. + * + * @param object|array &$array The input array. + * + * @return mixed + * @throws ArrayException + * + */ +function end(&$array) +{ + error_clear_last(); + $result = \end($array); + if ($result === false) { + throw ArrayException::createFromPhpError(); + } + + return $result; +} + + +/** + * This function will advance the internal pointer of an array. + * + * @param object|array &$array The input array. + * + * @return mixed + * @throws ArrayException + * + */ +function next(&$array) +{ + error_clear_last(); + $result = \next($array); + if ($result === false) { + throw ArrayException::createFromPhpError(); + } + + return $result; +} + + +/** + * This function will rewind the internal array pointer. + * + * @param object|array &$array The input array. + * + * @return mixed + * @throws ArrayException + * + */ +function prev(&$array) +{ + error_clear_last(); + $result = \prev($array); + if ($result === false) { + throw ArrayException::createFromPhpError(); + } + + return $result; +} + + +/** + * This function will set the internal pointer of an array to its first element. + * + * @param object|array &$array The input array. + * + * @return mixed + * @throws ArrayException + * + */ +function reset(&$array) +{ + error_clear_last(); + $result = \reset($array); + if ($result === false) { + throw ArrayException::createFromPhpError(); + } + + return $result; +}