Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add several functions #263

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions generated/array.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}