From 1e7bbf8ee1b7c3024ca6a74f5f2f55b4223ba04e Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Mon, 5 Jul 2021 11:35:03 +0200 Subject: [PATCH] feature: support head() and last() --- stubs/helpers.stubphp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/stubs/helpers.stubphp b/stubs/helpers.stubphp index 5862f5b..f40c377 100644 --- a/stubs/helpers.stubphp +++ b/stubs/helpers.stubphp @@ -81,6 +81,32 @@ class NullObject { } } +/** + * Get the first element of an array. Useful for method chaining. + * + * @template TValue + * @template TParam of TValue[] + * @param TParam $array + * @return (TParam is non-empty-array ? TValue : false) + */ +function head($array) +{ + return reset($array); +} + +/** + * Get the last element from an array. + * + * @template TValue + * @template TParam of TValue[] + * @param TParam $array + * @return (TParam is non-empty-array ? TValue : false) + */ +function last($array) +{ + +} + /** * Provide access to optional objects. *