Skip to content

Commit

Permalink
Add array_combine
Browse files Browse the repository at this point in the history
  • Loading branch information
jderusse authored and moufmouf committed Nov 13, 2018
1 parent 70cdfb7 commit 4547d46
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 1 deletion.
24 changes: 24 additions & 0 deletions generated/array.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,30 @@

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_multisort can be used to sort several
* arrays at once, or a multi-dimensional array by one or more
Expand Down
1 change: 1 addition & 0 deletions generated/functionsList.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
'apcu_delete',
'apcu_inc',
'apcu_sma_info',
'array_combine',
'array_multisort',
'array_walk_recursive',
'arsort',
Expand Down
2 changes: 1 addition & 1 deletion generated/network.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ function inet_ntop(string $in_addr): string
*
*
*
* You can use one or more of this options. When using multiple options
* You can use one or more of these options. When using multiple options
* you need to OR them, i.e. to open the connection
* immediately, write to the console and include the PID in each message,
* you will use: LOG_CONS | LOG_NDELAY | LOG_PID
Expand Down
3 changes: 3 additions & 0 deletions generator/src/DocPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public function detectFalsyFunction(): bool
if (preg_match('/ or &false; \\(and generates an error/m', $file)) {
return true;
}
if (preg_match('/&false;\s+if\s+the\s+number\s+of\s+elements\s+for\s+each\s+array\s+isn\'t\s+equal/m', $file)) {
return true;
}

return false;
}
Expand Down
1 change: 1 addition & 0 deletions rector-migrate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ services:
apcu_delete: 'Safe\apcu_delete'
apcu_inc: 'Safe\apcu_inc'
apcu_sma_info: 'Safe\apcu_sma_info'
array_combine: 'Safe\array_combine'
array_multisort: 'Safe\array_multisort'
array_walk_recursive: 'Safe\array_walk_recursive'
arsort: 'Safe\arsort'
Expand Down

0 comments on commit 4547d46

Please sign in to comment.