From 4547d4684086d463b00cbd1a7763395280355e7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Fri, 9 Nov 2018 10:27:07 +0100 Subject: [PATCH] Add array_combine --- generated/array.php | 24 ++++++++++++++++++++++++ generated/functionsList.php | 1 + generated/network.php | 2 +- generator/src/DocPage.php | 3 +++ rector-migrate.yml | 1 + 5 files changed, 30 insertions(+), 1 deletion(-) diff --git a/generated/array.php b/generated/array.php index ecde0ef6..4a6b844f 100644 --- a/generated/array.php +++ b/generated/array.php @@ -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 diff --git a/generated/functionsList.php b/generated/functionsList.php index b93b817c..bc288400 100644 --- a/generated/functionsList.php +++ b/generated/functionsList.php @@ -25,6 +25,7 @@ 'apcu_delete', 'apcu_inc', 'apcu_sma_info', + 'array_combine', 'array_multisort', 'array_walk_recursive', 'arsort', diff --git a/generated/network.php b/generated/network.php index 67f709ec..1d0ec021 100644 --- a/generated/network.php +++ b/generated/network.php @@ -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 diff --git a/generator/src/DocPage.php b/generator/src/DocPage.php index ddcc1a85..eae0a36d 100644 --- a/generator/src/DocPage.php +++ b/generator/src/DocPage.php @@ -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; } diff --git a/rector-migrate.yml b/rector-migrate.yml index ec18956d..c0ab59fe 100644 --- a/rector-migrate.yml +++ b/rector-migrate.yml @@ -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'