diff --git a/deprecated/array.php b/deprecated/array.php index f0b3a20b..691ea739 100644 --- a/deprecated/array.php +++ b/deprecated/array.php @@ -4,6 +4,79 @@ use Safe\Exceptions\ArrayException; +/** + * array_replace_recursive replaces the values of + * array with the same values from all the following + * arrays. If a key from the first array exists in the second array, its value + * will be replaced by the value from the second array. If the key exists in the + * second array, and not the first, it will be created in the first array. + * If a key only exists in the first array, it will be left as is. + * If several arrays are passed for replacement, they will be processed + * in order, the later array overwriting the previous values. + * + * array_replace_recursive is recursive : it will recurse into + * arrays and apply the same process to the inner value. + * + * When the value in the first array is scalar, it will be replaced + * by the value in the second array, may it be scalar or array. + * When the value in the first array and the second array + * are both arrays, array_replace_recursive will replace + * their respective value recursively. + * + * @param array $array The array in which elements are replaced. + * @param array $replacements Arrays from which elements will be extracted. + * @return array Returns an array. + * @throws ArrayException + * + */ +function array_replace_recursive(array $array, array ...$replacements): array +{ + error_clear_last(); + if ($replacements !== []) { + $result = \array_replace_recursive($array, ...$replacements); + } else { + $result = \array_replace_recursive($array); + } + if ($result === null) { + throw ArrayException::createFromPhpError(); + } + return $result; +} + +/** + * array_replace replaces the values of + * array with values having the same keys in each of the following + * arrays. If a key from the first array exists in the second array, its value + * will be replaced by the value from the second array. If the key exists in the + * second array, and not the first, it will be created in the first array. + * If a key only exists in the first array, it will be left as is. + * If several arrays are passed for replacement, they will be processed + * in order, the later arrays overwriting the previous values. + * + * array_replace is not recursive : it will replace + * values in the first array by whatever type is in the second array. + * + * @param array $array The array in which elements are replaced. + * @param array $replacements Arrays from which elements will be extracted. + * Values from later arrays overwrite the previous values. + * @return array Returns an array. + * @throws ArrayException + * + */ +function array_replace(array $array, array ...$replacements): array +{ + error_clear_last(); + if ($replacements !== []) { + $result = \array_replace($array, ...$replacements); + } else { + $result = \array_replace($array); + } + if ($result === null) { + throw ArrayException::createFromPhpError(); + } + return $result; +} + /** * array_flip returns an array in flip * order, i.e. keys from array become values and values diff --git a/deprecated/functionsList.php b/deprecated/functionsList.php index 6b39199c..b75d7abb 100644 --- a/deprecated/functionsList.php +++ b/deprecated/functionsList.php @@ -12,6 +12,8 @@ 'apc_load_constants', 'apc_sma_info', 'arsort', + 'array_replace', + 'array_replace_recursive', 'array_combine', 'array_flip', 'asort', diff --git a/generated/array.php b/generated/array.php index 37fa077a..39a77b5e 100644 --- a/generated/array.php +++ b/generated/array.php @@ -4,81 +4,6 @@ use Safe\Exceptions\ArrayException; -/** - * array_replace_recursive replaces the values of - * array with the same values from all the following - * arrays. If a key from the first array exists in the second array, its value - * will be replaced by the value from the second array. If the key exists in the - * second array, and not the first, it will be created in the first array. - * If a key only exists in the first array, it will be left as is. - * If several arrays are passed for replacement, they will be processed - * in order, the later array overwriting the previous values. - * - * array_replace_recursive is recursive : it will recurse into - * arrays and apply the same process to the inner value. - * - * When the value in the first array is scalar, it will be replaced - * by the value in the second array, may it be scalar or array. - * When the value in the first array and the second array - * are both arrays, array_replace_recursive will replace - * their respective value recursively. - * - * @param array $array The array in which elements are replaced. - * @param array $replacements Arrays from which elements will be extracted. - * @return array Returns an array. - * @throws ArrayException - * - */ -function array_replace_recursive(array $array, array ...$replacements): array -{ - error_clear_last(); - if ($replacements !== []) { - $result = \array_replace_recursive($array, ...$replacements); - } else { - $result = \array_replace_recursive($array); - } - if ($result === null) { - throw ArrayException::createFromPhpError(); - } - return $result; -} - - -/** - * array_replace replaces the values of - * array with values having the same keys in each of the following - * arrays. If a key from the first array exists in the second array, its value - * will be replaced by the value from the second array. If the key exists in the - * second array, and not the first, it will be created in the first array. - * If a key only exists in the first array, it will be left as is. - * If several arrays are passed for replacement, they will be processed - * in order, the later arrays overwriting the previous values. - * - * array_replace is not recursive : it will replace - * values in the first array by whatever type is in the second array. - * - * @param array $array The array in which elements are replaced. - * @param array $replacements Arrays from which elements will be extracted. - * Values from later arrays overwrite the previous values. - * @return array Returns an array. - * @throws ArrayException - * - */ -function array_replace(array $array, array ...$replacements): array -{ - error_clear_last(); - if ($replacements !== []) { - $result = \array_replace($array, ...$replacements); - } else { - $result = \array_replace($array); - } - if ($result === null) { - throw ArrayException::createFromPhpError(); - } - return $result; -} - - /** * Applies the user-defined callback function to each * element of the array. This function will recurse diff --git a/generated/curl.php b/generated/curl.php index cbb05cd6..6473b6d2 100644 --- a/generated/curl.php +++ b/generated/curl.php @@ -2588,7 +2588,7 @@ function curl_multi_setopt(\CurlMultiHandle $multi_handle, int $option, $value): * * CURLOPT_PROXY_TLSAUTH_USERNAME * - * Tusername to use for the HTTPS proxy TLS authentication method specified with the + * The username to use for the HTTPS proxy TLS authentication method specified with the * CURLOPT_PROXY_TLSAUTH_TYPE option. Requires that the * CURLOPT_PROXY_TLSAUTH_PASSWORD option to also be set. * diff --git a/generated/exec.php b/generated/exec.php index c4dd4911..126438d4 100644 --- a/generated/exec.php +++ b/generated/exec.php @@ -85,10 +85,10 @@ function passthru(string $command, ?int &$result_code = null): void * @param int $priority The new priority value, the value of this may differ on platforms. * * On Unix, a low value, such as -20 means high priority - * wheras a positive value have a lower priority. + * whereas positive values have a lower priority. * - * For Windows the priority parameter have the - * following meanings: + * For Windows the priority parameter has the + * following meaning: * @throws ExecException * */ diff --git a/generated/filesystem.php b/generated/filesystem.php index 7f1b08bb..f3e5a208 100644 --- a/generated/filesystem.php +++ b/generated/filesystem.php @@ -1240,6 +1240,13 @@ function lstat(string $filename): array * Attempts to create the directory specified by directory. * * @param string $directory The directory path. + * A URL can be used as a + * filename with this function if the fopen wrappers have been enabled. + * See fopen for more details on how to specify the + * filename. See the for links to information + * about what abilities the various wrappers have, notes on their usage, + * and information on any predefined variables they may + * provide. * @param int $permissions The permissions are 0777 by default, which means the widest possible * access. For more information on permissions, read the details * on the chmod page. @@ -1250,8 +1257,8 @@ function lstat(string $filename): array * which means it should have a leading zero. The permissions is also modified * by the current umask, which you can change using * umask. - * @param bool $recursive Allows the creation of nested directories specified in the - * directory. + * @param bool $recursive If TRUE, then any parent directories to the directory specified will + * also be created, with the same permissions. * @param resource $context A context stream * resource. * @throws FilesystemException diff --git a/generated/functionsList.php b/generated/functionsList.php index 3c537d1f..5a590058 100644 --- a/generated/functionsList.php +++ b/generated/functionsList.php @@ -14,8 +14,6 @@ 'apcu_inc', 'apcu_sma_info', 'apc_fetch', - 'array_replace', - 'array_replace_recursive', 'array_walk_recursive', 'assert_options', 'base64_decode', diff --git a/generated/json.php b/generated/json.php index 76fc6c17..e524c617 100644 --- a/generated/json.php +++ b/generated/json.php @@ -6,7 +6,12 @@ /** * Returns a string containing the JSON representation of the supplied - * value. + * value. If the parameter is an array or object, + * it will be serialized recursively. + * + * If a value to be serialized is an object, then by default only publicly visible + * properties will be included. Alternatively, a class may implement JsonSerializable + * to control how its values are serialized to JSON. * * The encoding is affected by the supplied flags * and additionally the encoding of float values depends on the value of diff --git a/generated/ldap.php b/generated/ldap.php index 97b42e5a..0bfaaaf2 100644 --- a/generated/ldap.php +++ b/generated/ldap.php @@ -239,36 +239,36 @@ function ldap_exop_whoami($ldap) /** - * Performs an extended operation on the specified link with - * reqoid the OID of the operation and - * reqdata the data. + * Performs an extended operation on the specified ldap with + * request_oid the OID of the operation and + * request_data the data. * * @param resource $ldap An LDAP\Connection instance, returned by ldap_connect. - * @param string $reqoid The extended operation request OID. You may use one of LDAP_EXOP_START_TLS, LDAP_EXOP_MODIFY_PASSWD, LDAP_EXOP_REFRESH, LDAP_EXOP_WHO_AM_I, LDAP_EXOP_TURN, or a string with the OID of the operation you want to send. - * @param string $reqdata The extended operation request data. May be NULL for some operations like LDAP_EXOP_WHO_AM_I, may also need to be BER encoded. - * @param array|null $serverctrls Array of LDAP Controls to send with the request. - * @param string|null $retdata Will be filled with the extended operation response data if provided. + * @param string $request_oid The extended operation request OID. You may use one of LDAP_EXOP_START_TLS, LDAP_EXOP_MODIFY_PASSWD, LDAP_EXOP_REFRESH, LDAP_EXOP_WHO_AM_I, LDAP_EXOP_TURN, or a string with the OID of the operation you want to send. + * @param string $request_data The extended operation request data. May be NULL for some operations like LDAP_EXOP_WHO_AM_I, may also need to be BER encoded. + * @param array|null $controls Array of LDAP Controls to send with the request. + * @param string|null $response_data Will be filled with the extended operation response data if provided. * If not provided you may use ldap_parse_exop on the result object * later to get this data. - * @param string|null $retoid Will be filled with the response OID if provided, usually equal to the request OID. - * @return resource|bool When used with retdata, returns TRUE on success. - * When used without retdata, returns a result identifier. + * @param string|null $response_oid Will be filled with the response OID if provided, usually equal to the request OID. + * @return resource|bool When used with response_data, returns TRUE on success. + * When used without response_data, returns a result identifier. * @throws LdapException * */ -function ldap_exop($ldap, string $reqoid, string $reqdata = null, ?array $serverctrls = null, ?string &$retdata = null, ?string &$retoid = null) +function ldap_exop($ldap, string $request_oid, string $request_data = null, ?array $controls = null, ?string &$response_data = null, ?string &$response_oid = null) { error_clear_last(); - if ($retoid !== null) { - $result = \ldap_exop($ldap, $reqoid, $reqdata, $serverctrls, $retdata, $retoid); - } elseif ($retdata !== null) { - $result = \ldap_exop($ldap, $reqoid, $reqdata, $serverctrls, $retdata); - } elseif ($serverctrls !== null) { - $result = \ldap_exop($ldap, $reqoid, $reqdata, $serverctrls); - } elseif ($reqdata !== null) { - $result = \ldap_exop($ldap, $reqoid, $reqdata); + if ($response_oid !== null) { + $result = \ldap_exop($ldap, $request_oid, $request_data, $controls, $response_data, $response_oid); + } elseif ($response_data !== null) { + $result = \ldap_exop($ldap, $request_oid, $request_data, $controls, $response_data); + } elseif ($controls !== null) { + $result = \ldap_exop($ldap, $request_oid, $request_data, $controls); + } elseif ($request_data !== null) { + $result = \ldap_exop($ldap, $request_oid, $request_data); } else { - $result = \ldap_exop($ldap, $reqoid); + $result = \ldap_exop($ldap, $request_oid); } if ($result === false) { throw LdapException::createFromPhpError(); diff --git a/generated/pcntl.php b/generated/pcntl.php index 66cc28d4..d05f7ff3 100644 --- a/generated/pcntl.php +++ b/generated/pcntl.php @@ -11,8 +11,9 @@ * man page for specific details. * * @param int $process_id If NULL, the process id of the current process is used. - * @param int $mode One of PRIO_PGRP, PRIO_USER - * or PRIO_PROCESS. + * @param int $mode One of PRIO_PGRP, PRIO_USER, + * PRIO_PROCESS, + * PRIO_DARWIN_BG or PRIO_DARWIN_THREAD. * @return int pcntl_getpriority returns the priority of the process. A lower numerical value causes more favorable * scheduling. * @throws PcntlException @@ -46,8 +47,9 @@ function pcntl_getpriority(int $process_id = null, int $mode = PRIO_PROCESS): in * system types and kernel versions, please see your system's setpriority(2) * man page for specific details. * @param int $process_id If NULL, the process id of the current process is used. - * @param int $mode One of PRIO_PGRP, PRIO_USER - * or PRIO_PROCESS. + * @param int $mode One of PRIO_PGRP, PRIO_USER, + * PRIO_PROCESS, + * PRIO_DARWIN_BG or PRIO_DARWIN_THREAD. * @throws PcntlException * */ diff --git a/generator/tests/DocPageTest.php b/generator/tests/DocPageTest.php index 6a2ab878..f861b604 100644 --- a/generator/tests/DocPageTest.php +++ b/generator/tests/DocPageTest.php @@ -44,10 +44,8 @@ public function testDetectFalsyFunction() public function testDetectNullsyFunction() { $implode = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/strings/functions/implode.xml'); - $arrayReplace = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/array/functions/array-replace.xml'); $this->assertFalse($implode->detectNullsyFunction()); - $this->assertTrue($arrayReplace->detectNullsyFunction()); } public function testDetectEmptyFunction() diff --git a/rector-migrate.php b/rector-migrate.php index efa2a286..4f17de5e 100644 --- a/rector-migrate.php +++ b/rector-migrate.php @@ -24,8 +24,6 @@ 'apcu_inc' => 'Safe\apcu_inc', 'apcu_sma_info' => 'Safe\apcu_sma_info', 'apc_fetch' => 'Safe\apc_fetch', - 'array_replace' => 'Safe\array_replace', - 'array_replace_recursive' => 'Safe\array_replace_recursive', 'array_walk_recursive' => 'Safe\array_walk_recursive', 'assert_options' => 'Safe\assert_options', 'base64_decode' => 'Safe\base64_decode',