Skip to content

Commit

Permalink
Merge pull request #346 from thecodingmachine/array_combine
Browse files Browse the repository at this point in the history
FEATURE: array_combine is now deprecated
  • Loading branch information
Kharhamel authored Apr 19, 2022
2 parents dc50e64 + 5fa18de commit ae2e60d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 26 deletions.
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

0 comments on commit ae2e60d

Please sign in to comment.