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

FEATURE: array_combine is now deprecated #346

Merged
merged 1 commit into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
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
24 changes: 24 additions & 0 deletions deprecated/array.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,27 @@ function usort(array &$array, callable $value_compare_func): void
throw ArrayException::createFromPhpError();
}
}

/**
* Creates an array by using the values from the
* keys array as keys and the values from the
* values array as the corresponding values.
*
* @param array $keys Array of keys to be used. Illegal values for key will be
* converted to string.
* @param array $values Array of values to be used
* @return array Returns the combined array, FALSE if the number of elements
* for each array isn't equal.
* @throws ArrayException
* @deprecated
*
*/
function array_combine(array $keys, array $values): array
{
error_clear_last();
$result = \array_combine($keys, $values);
if ($result === false) {
throw ArrayException::createFromPhpError();
}
return $result;
}
1 change: 1 addition & 0 deletions deprecated/functionsList.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
'apc_load_constants',
'apc_sma_info',
'arsort',
'array_combine',
'array_flip',
'asort',
'event_add',
Expand Down
24 changes: 0 additions & 24 deletions generated/array.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,6 @@

use Safe\Exceptions\ArrayException;

/**
* Creates an array by using the values from the
* keys array as keys and the values from the
* values array as the corresponding values.
*
* @param array $keys Array of keys to be used. Illegal values for key will be
* converted to string.
* @param array $values Array of values to be used
* @return array Returns the combined array, FALSE if the number of elements
* for each array isn't equal.
* @throws ArrayException
*
*/
function array_combine(array $keys, array $values): array
{
error_clear_last();
$result = \array_combine($keys, $values);
if ($result === false) {
throw ArrayException::createFromPhpError();
}
return $result;
}


/**
* array_replace_recursive replaces the values of
* array with the same values from all the following
Expand Down
1 change: 0 additions & 1 deletion generated/functionsList.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
'apcu_inc',
'apcu_sma_info',
'apc_fetch',
'array_combine',
'array_replace',
'array_replace_recursive',
'array_walk_recursive',
Expand Down
1 change: 0 additions & 1 deletion rector-migrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
'apcu_inc' => 'Safe\apcu_inc',
'apcu_sma_info' => 'Safe\apcu_sma_info',
'apc_fetch' => 'Safe\apc_fetch',
'array_combine' => 'Safe\array_combine',
'array_replace' => 'Safe\array_replace',
'array_replace_recursive' => 'Safe\array_replace_recursive',
'array_walk_recursive' => 'Safe\array_walk_recursive',
Expand Down