From 017e0ff03a907c4d65d2273b27f814c77097b960 Mon Sep 17 00:00:00 2001 From: arp Date: Tue, 28 Dec 2021 18:24:56 +0100 Subject: [PATCH] FEATURE: deprecated the module mysqli and regenerated the files --- composer.json | 2 +- .../Exceptions/MysqliException.php | 0 deprecated/functionsList.php | 1 + {generated => deprecated}/mysqli.php | 0 generated/array.php | 30 --- generated/curl.php | 2 +- generated/errorfunc.php | 10 +- generated/filesystem.php | 121 ++++++--- generated/ftp.php | 22 ++ generated/functionsList.php | 11 +- generated/image.php | 29 +-- generated/imap.php | 14 +- generated/network.php | 105 ++++++++ generated/oci8.php | 36 +++ generated/openssl.php | 14 +- generated/stream.php | 242 ++++++++++++++---- generated/zlib.php | 4 +- generator/tests/DocPageTest.php | 2 - rector-migrate.php | 11 +- 19 files changed, 492 insertions(+), 164 deletions(-) rename {generated => deprecated}/Exceptions/MysqliException.php (100%) rename {generated => deprecated}/mysqli.php (100%) diff --git a/composer.json b/composer.json index fa5319ba..6af9ffe2 100644 --- a/composer.json +++ b/composer.json @@ -16,6 +16,7 @@ "deprecated/mssql.php", "deprecated/stats.php", "lib/special_cases.php", + "deprecated/mysqli.php", "generated/apache.php", "generated/apcu.php", "generated/array.php", @@ -55,7 +56,6 @@ "generated/mbstring.php", "generated/misc.php", "generated/mysql.php", - "generated/mysqli.php", "generated/network.php", "generated/oci8.php", "generated/opcache.php", diff --git a/generated/Exceptions/MysqliException.php b/deprecated/Exceptions/MysqliException.php similarity index 100% rename from generated/Exceptions/MysqliException.php rename to deprecated/Exceptions/MysqliException.php diff --git a/deprecated/functionsList.php b/deprecated/functionsList.php index e430cd3b..c032c589 100644 --- a/deprecated/functionsList.php +++ b/deprecated/functionsList.php @@ -48,6 +48,7 @@ 'mssql_pconnect', 'mssql_query', 'mssql_select_db', + 'mysqli_get_client_stats', 'stats_covariance', 'stats_standard_deviation', 'stats_stat_correlation', diff --git a/generated/mysqli.php b/deprecated/mysqli.php similarity index 100% rename from generated/mysqli.php rename to deprecated/mysqli.php diff --git a/generated/array.php b/generated/array.php index c433186b..f1fe2bde 100644 --- a/generated/array.php +++ b/generated/array.php @@ -28,36 +28,6 @@ function array_combine(array $keys, array $values): array } -/** - * array_flip returns an array in flip - * order, i.e. keys from array become values and values - * from array become keys. - * - * Note that the values of array need to be valid - * keys, i.e. they need to be either int or - * string. A warning will be emitted if a value has the wrong - * type, and the key/value pair in question will not be included - * in the result. - * - * If a value has several occurrences, the latest key will be - * used as its value, and all others will be lost. - * - * @param array $array An array of key/value pairs to be flipped. - * @return array Returns the flipped array on success. - * @throws ArrayException - * - */ -function array_flip(array $array): array -{ - error_clear_last(); - $result = \array_flip($array); - if ($result === null) { - throw ArrayException::createFromPhpError(); - } - return $result; -} - - /** * array_replace_recursive replaces the values of * array with the same values from all the following diff --git a/generated/curl.php b/generated/curl.php index 97b0cd49..ce3e87ed 100644 --- a/generated/curl.php +++ b/generated/curl.php @@ -2354,7 +2354,7 @@ function curl_multi_setopt($multi_handle, int $option, $value): void * multipart/form-data. * * - * Files can be sent using CURLFile, + * Files can be sent using CURLFile or CURLStringFile, * in which case value must be an array. * * diff --git a/generated/errorfunc.php b/generated/errorfunc.php index ac64a7d8..9d3e98b2 100644 --- a/generated/errorfunc.php +++ b/generated/errorfunc.php @@ -30,7 +30,7 @@ * message is sent by email to the address in * the destination parameter. This is the only * message type where the fourth parameter, - * extra_headers is used. + * additional_headers is used. * * * @@ -59,18 +59,18 @@ * * @param string $destination The destination. Its meaning depends on the * message_type parameter as described above. - * @param string $extra_headers The extra headers. It's used when the message_type + * @param string $additional_headers The extra headers. It's used when the message_type * parameter is set to 1. * This message type uses the same internal function as * mail does. * @throws ErrorfuncException * */ -function error_log(string $message, int $message_type = 0, string $destination = null, string $extra_headers = null): void +function error_log(string $message, int $message_type = 0, string $destination = null, string $additional_headers = null): void { error_clear_last(); - if ($extra_headers !== null) { - $result = \error_log($message, $message_type, $destination, $extra_headers); + if ($additional_headers !== null) { + $result = \error_log($message, $message_type, $destination, $additional_headers); } elseif ($destination !== null) { $result = \error_log($message, $message_type, $destination); } else { diff --git a/generated/filesystem.php b/generated/filesystem.php index ca46c216..223c572a 100644 --- a/generated/filesystem.php +++ b/generated/filesystem.php @@ -89,13 +89,13 @@ function chown(string $filename, $user): void /** - * Makes a copy of the file source to - * dest. + * Makes a copy of the file from to + * to. * * If you wish to move a file, use the rename function. * - * @param string $source Path to the source file. - * @param string $dest The destination path. If dest is a URL, the + * @param string $from Path to the source file. + * @param string $to The destination path. If to is a URL, the * copy operation may fail if the wrapper does not support overwriting of * existing files. * @@ -105,13 +105,13 @@ function chown(string $filename, $user): void * @throws FilesystemException * */ -function copy(string $source, string $dest, $context = null): void +function copy(string $from, string $to, $context = null): void { error_clear_last(); if ($context !== null) { - $result = \copy($source, $dest, $context); + $result = \copy($from, $to, $context); } else { - $result = \copy($source, $dest); + $result = \copy($from, $to); } if ($result === false) { throw FilesystemException::createFromPhpError(); @@ -226,6 +226,52 @@ function fflush($stream): void } +/** + * Similar to fgets except that + * fgetcsv parses the line it reads for fields in + * CSV format and returns an array containing the fields + * read. + * + * @param resource $stream A valid file pointer to a file successfully opened by + * fopen, popen, or + * fsockopen. + * @param int $length Must be greater than the longest line (in characters) to be found in + * the CSV file (allowing for trailing line-end characters). Otherwise the + * line is split in chunks of length characters, + * unless the split would occur inside an enclosure. + * + * Omitting this parameter (or setting it to 0, + * or NULL in PHP 8.0.0 or later) the maximum line length is not limited, + * which is slightly slower. + * @param string $separator The optional separator parameter sets the field separator (one single-byte character only). + * @param string $enclosure The optional enclosure parameter sets the field enclosure character (one single-byte character only). + * @param string $escape The optional escape parameter sets the escape character (at most one single-byte character). + * An empty string ("") disables the proprietary escape mechanism. + * @return array|false|null Returns an indexed array containing the fields read on success. + * @throws FilesystemException + * + */ +function fgetcsv($stream, int $length = null, string $separator = ",", string $enclosure = "\"", string $escape = "\\") +{ + error_clear_last(); + if ($escape !== "\\") { + $result = \fgetcsv($stream, $length, $separator, $enclosure, $escape); + } elseif ($enclosure !== "\"") { + $result = \fgetcsv($stream, $length, $separator, $enclosure); + } elseif ($separator !== ",") { + $result = \fgetcsv($stream, $length, $separator); + } elseif ($length !== null) { + $result = \fgetcsv($stream, $length); + } else { + $result = \fgetcsv($stream); + } + if ($result === false) { + throw FilesystemException::createFromPhpError(); + } + return $result; +} + + /** * This function is similar to file, except that * file_get_contents returns the file in a @@ -872,7 +918,7 @@ function fopen(string $filename, string $mode, bool $use_include_path = false, $ * @throws FilesystemException * */ -function fputcsv($stream, array $fields, string $separator = ",", string $enclosure = '"', string $escape = "\\", string $eol = "\n"): int +function fputcsv($stream, array $fields, string $separator = ",", string $enclosure = "\"", string $escape = "\\", string $eol = "\n"): int { error_clear_last(); $result = \fputcsv($stream, $fields, $separator, $enclosure, $escape, $eol); @@ -1009,24 +1055,23 @@ function ftruncate($stream, int $size): void /** * * - * @param resource $handle A file system pointer resource + * @param resource $stream A file system pointer resource * that is typically created using fopen. - * @param string $string The string that is to be written. - * @param int $length If the length argument is given, writing will - * stop after length bytes have been written or - * the end of string is reached, whichever comes - * first. + * @param string $data The string that is to be written. + * @param int $length If length is an integer, writing will stop + * after length bytes have been written or the + * end of data is reached, whichever comes first. * @return int * @throws FilesystemException * */ -function fwrite($handle, string $string, int $length = null): int +function fwrite($stream, string $data, int $length = null): int { error_clear_last(); if ($length !== null) { - $result = \fwrite($handle, $string, $length); + $result = \fwrite($stream, $data, $length); } else { - $result = \fwrite($handle, $string); + $result = \fwrite($stream, $data); } if ($result === false) { throw FilesystemException::createFromPhpError(); @@ -1420,22 +1465,22 @@ function realpath(string $path): string /** - * Attempts to rename oldname to - * newname, moving it between directories if necessary. - * If renaming a file and newname exists, + * Attempts to rename from to + * to, moving it between directories if necessary. + * If renaming a file and to exists, * it will be overwritten. If renaming a directory and - * newname exists, + * to exists, * this function will emit a warning. * - * @param string $oldname The old name. + * @param string $from The old name. * - * The wrapper used in oldname + * The wrapper used in from * must match the wrapper used in - * newname. - * @param string $newname The new name. + * to. + * @param string $to The new name. * * - * On Windows, if newname already exists, it must be writable. + * On Windows, if to already exists, it must be writable. * Otherwise rename fails and issues E_WARNING. * * @@ -1444,13 +1489,13 @@ function realpath(string $path): string * @throws FilesystemException * */ -function rename(string $oldname, string $newname, $context = null): void +function rename(string $from, string $to, $context = null): void { error_clear_last(); if ($context !== null) { - $result = \rename($oldname, $newname, $context); + $result = \rename($from, $to, $context); } else { - $result = \rename($oldname, $newname); + $result = \rename($from, $to); } if ($result === false) { throw FilesystemException::createFromPhpError(); @@ -1573,29 +1618,29 @@ function tmpfile() /** * Attempts to set the access and modification times of the file named in the * filename parameter to the value given in - * time. + * mtime. * Note that the access time is always modified, regardless of the number * of parameters. * * If the file does not exist, it will be created. * * @param string $filename The name of the file being touched. - * @param int $time The touch time. If time is not supplied, + * @param int $mtime The touch time. If mtime is NULL, * the current system time is used. - * @param int $atime If present, the access time of the given filename is set to + * @param int $atime If NULL, the access time of the given filename is set to * the value of atime. Otherwise, it is set to - * the value passed to the time parameter. - * If neither are present, the current system time is used. + * the value passed to the mtime parameter. + * If both are NULL, the current system time is used. * @throws FilesystemException * */ -function touch(string $filename, int $time = null, int $atime = null): void +function touch(string $filename, int $mtime = null, int $atime = null): void { error_clear_last(); if ($atime !== null) { - $result = \touch($filename, $time, $atime); - } elseif ($time !== null) { - $result = \touch($filename, $time); + $result = \touch($filename, $mtime, $atime); + } elseif ($mtime !== null) { + $result = \touch($filename, $mtime); } else { $result = \touch($filename); } diff --git a/generated/ftp.php b/generated/ftp.php index cb6ce176..23846bf1 100644 --- a/generated/ftp.php +++ b/generated/ftp.php @@ -411,6 +411,28 @@ function ftp_pwd($ftp): string } +/** + * Sends an arbitrary command to the FTP server. + * + * @param resource $ftp An FTP\Connection instance. + * @param string $command The command to execute. + * @return array Returns the server's response as an array of strings. + * No parsing is performed on the response string, nor does + * ftp_raw determine if the command succeeded. + * @throws FtpException + * + */ +function ftp_raw($ftp, string $command): array +{ + error_clear_last(); + $result = \ftp_raw($ftp, $command); + if ($result === null) { + throw FtpException::createFromPhpError(); + } + return $result; +} + + /** * ftp_rename renames a file or a directory on the FTP * server. diff --git a/generated/functionsList.php b/generated/functionsList.php index 740e8104..f5970b52 100644 --- a/generated/functionsList.php +++ b/generated/functionsList.php @@ -15,7 +15,6 @@ 'apcu_sma_info', 'apc_fetch', 'array_combine', - 'array_flip', 'array_replace', 'array_replace_recursive', 'array_walk_recursive', @@ -181,6 +180,7 @@ 'fclose', 'fdatasync', 'fflush', + 'fgetcsv', 'file', 'fileatime', 'filectime', @@ -221,6 +221,7 @@ 'ftp_pasv', 'ftp_put', 'ftp_pwd', + 'ftp_raw', 'ftp_rename', 'ftp_rmdir', 'ftp_site', @@ -321,7 +322,6 @@ 'imagecolordeallocate', 'imagecolormatch', 'imagecolorset', - 'imagecolorsforindex', 'imageconvolution', 'imagecopy', 'imagecopymerge', @@ -529,7 +529,6 @@ 'msg_send', 'msg_set_queue', 'msg_stat_queue', - 'mysqli_get_client_stats', 'mysql_close', 'mysql_connect', 'mysql_create_db', @@ -561,6 +560,7 @@ 'mysql_tablename', 'mysql_thread_id', 'mysql_unbuffered_query', + 'net_get_interfaces', 'ob_clean', 'ob_end_clean', 'ob_end_flush', @@ -600,6 +600,7 @@ 'oci_set_edition', 'oci_set_module_name', 'oci_set_prefetch', + 'oci_set_prefetch_lob', 'oci_statement_type', 'oci_unregister_taf_callback', 'odbc_autocommit', @@ -1007,13 +1008,17 @@ 'stream_filter_register', 'stream_filter_remove', 'stream_get_contents', + 'stream_get_line', 'stream_isatty', 'stream_resolve_include_path', 'stream_set_blocking', 'stream_set_timeout', 'stream_socket_accept', 'stream_socket_client', + 'stream_socket_get_name', 'stream_socket_pair', + 'stream_socket_recvfrom', + 'stream_socket_sendto', 'stream_socket_server', 'stream_socket_shutdown', 'stream_supports_lock', diff --git a/generated/image.php b/generated/image.php index b1fdfc36..91342964 100644 --- a/generated/image.php +++ b/generated/image.php @@ -503,28 +503,6 @@ function imagecolorset($image, int $color, int $red, int $green, int $blue, int } -/** - * Gets the color for a specified index. - * - * @param resource $image A GdImage object, returned by one of the image creation functions, - * such as imagecreatetruecolor. - * @param int $color The color index. - * @return array Returns an associative array with red, green, blue and alpha keys that - * contain the appropriate values for the specified color index. - * @throws ImageException - * - */ -function imagecolorsforindex($image, int $color): array -{ - error_clear_last(); - $result = \imagecolorsforindex($image, $color); - if ($result === false) { - throw ImageException::createFromPhpError(); - } - return $result; -} - - /** * Applies a convolution matrix on the image, using the given coefficient and * offset. @@ -976,6 +954,7 @@ function imagecreatefromwbmp(string $filename) /** * imagecreatefromwebp returns an image identifier * representing the image obtained from the given filename. + * Note that animated WebP files cannot be read. * * @param string $filename Path to the WebP image. * @return resource Returns an image object on success, FALSE on errors. @@ -1633,12 +1612,6 @@ function imageftbbox(float $size, float $angle, string $font_filename, string $s * to the filename and the library will attempt to search for that * filename along a library-defined font path. * - * When using versions of the GD library lower than 2.0.18, a space character, - * rather than a semicolon, was used as the 'path separator' for different font files. - * Unintentional use of this feature will result in the warning message: - * Warning: Could not find/open font. For these affected versions, the - * only solution is moving the font to a path which does not contain spaces. - * * In many cases where a font resides in the same directory as the script using it * the following trick will alleviate any include problems. * diff --git a/generated/imap.php b/generated/imap.php index f6e0fea9..2a694949 100644 --- a/generated/imap.php +++ b/generated/imap.php @@ -1381,7 +1381,8 @@ function imap_mail_compose(array $envelope, array $bodies): string * * * CP_MOVE - Delete the messages from - * the current mailbox after copying + * the current mailbox after copying. If this flag is set, the function + * behaves identically to imap_mail_move. * * * @@ -1401,6 +1402,9 @@ function imap_mail_copy($imap, string $message_nums, string $mailbox, int $flags /** * Moves mail messages specified by message_nums to the * specified mailbox. + * Note that the mail messages are actually copied to the + * mailbox, and the original messages are flagged for deletion. + * That implies that the messages in mailbox are assigned new UIDs. * * @param resource $imap An IMAP\Connection instance. * @param string $message_nums message_nums is a range not just message numbers @@ -2230,15 +2234,17 @@ function imap_timeout(int $timeout_type, int $timeout = -1) * imap_delete or imap_mail_move. * * @param resource $imap An IMAP\Connection instance. - * @param int $message_num The message number + * @param int $message_nums A string representing one or more messages in IMAP4-style sequence format + * ("n", "n:m", or combination of these + * delimited by commas). * @param int $flags * @throws ImapException * */ -function imap_undelete($imap, int $message_num, int $flags = 0): void +function imap_undelete($imap, int $message_nums, int $flags = 0): void { error_clear_last(); - $result = \imap_undelete($imap, $message_num, $flags); + $result = \imap_undelete($imap, $message_nums, $flags); if ($result === false) { throw ImapException::createFromPhpError(); } diff --git a/generated/network.php b/generated/network.php index ed167b1c..21186d1f 100644 --- a/generated/network.php +++ b/generated/network.php @@ -468,6 +468,111 @@ function long2ip(int $ip): string } +/** + * Returns an enumeration of network interfaces (adapters) on the local machine. + * + * @return array Returns an associative array where the key is the name of the interface and + * the value an associative array of interface attributes. + * + * Each interface associative array contains: + * + * Interface attributes + * + * + * + * Name + * Description + * + * + * + * + * description + * + * Optional string value for description of the interface. + * Windows only. + * + * + * + * mac + * + * Optional string value for MAC address of the interface. + * Windows only. + * + * + * + * mtu + * + * Integer value for Maximum transmission unit (MTU) of the interface. + * Windows only. + * + * + * + * unicast + * + * Array of associative arrays, see Unicast attributes below. + * + * + * + * up + * + * Boolean status (on/off) for interface. + * + * + * + * + * + * + * + * Unicast attributes + * + * + * + * Name + * Description + * + * + * + * + * flags + * + * Integer value. + * + * + * + * family + * + * Integer value. + * + * + * + * address + * + * String value for address in either IPv4 or IPv6. + * + * + * + * netmask + * + * String value for netmask in either IPv4 or IPv6. + * + * + * + * + * + * @throws NetworkException + * + */ +function net_get_interfaces(): array +{ + error_clear_last(); + $result = \net_get_interfaces(); + if ($result === false) { + throw NetworkException::createFromPhpError(); + } + return $result; +} + + /** * openlog opens a connection to the system * logger for a program. diff --git a/generated/oci8.php b/generated/oci8.php index c15116f7..002ae8f7 100644 --- a/generated/oci8.php +++ b/generated/oci8.php @@ -1462,6 +1462,42 @@ function oci_set_module_name($connection, string $name): void } +/** + * Sets the internal buffer size used to fetch each CLOB or BLOB value when the + * implementation gets the internal Oracle LOB locator from the database after + * a successful query call to oci_execute and for each + * subsequent internal fetch request to the database. Increasing this value + * can improve the performance of fetching smaller LOBs by reducing round-trips + * between PHP and the database. Memory usage will change. + * + * The value affects LOBs returned as OCI-Lob instances and also those returned + * using OCI_RETURN_LOBS. + * + * Call oci_set_prefetch_lob before + * calling oci_execute. If it is not called, the value + * of oci8.prefetch_lob_size + * is used. + * + * The LOB prefetch value should only be set with Oracle Database 12.2 or later. + * + * @param resource $statement A valid OCI8 statement + * identifier created by oci_parse and executed + * by oci_execute, or a REF + * CURSOR statement identifier. + * @param int $prefetch_lob_size The number of bytes of each LOB to be prefetched, >= 0 + * @throws Oci8Exception + * + */ +function oci_set_prefetch_lob($statement, int $prefetch_lob_size): void +{ + error_clear_last(); + $result = \oci_set_prefetch_lob($statement, $prefetch_lob_size); + if ($result === false) { + throw Oci8Exception::createFromPhpError(); + } +} + + /** * Sets the number of rows to be buffered by the Oracle Client * libraries after a successful query call diff --git a/generated/openssl.php b/generated/openssl.php index 9f0ea2fa..f81c6ee7 100644 --- a/generated/openssl.php +++ b/generated/openssl.php @@ -66,7 +66,7 @@ function openssl_cms_decrypt(string $input_filename, string $output_filename, $c * @throws OpensslException * */ -function openssl_cms_encrypt(string $input_filename, string $output_filename, $certificate, $headers, int $flags = 0, int $encoding = OPENSSL_ENCODING_SMIME, int $cipher_algo = OPENSSL_CIPHER_RC2_40): void +function openssl_cms_encrypt(string $input_filename, string $output_filename, $certificate, $headers, int $flags = 0, int $encoding = OPENSSL_ENCODING_SMIME, int $cipher_algo = OPENSSL_CIPHER_AES_128_CBC): void { error_clear_last(); $result = \openssl_cms_encrypt($input_filename, $output_filename, $certificate, $headers, $flags, $encoding, $cipher_algo); @@ -448,10 +448,16 @@ function openssl_csr_sign($csr, $ca_certificate, $private_key, int $days, array * @throws OpensslException * */ -function openssl_decrypt(string $data, string $cipher_algo, string $passphrase, int $options = 0, string $iv = "", string $tag = "", string $aad = ""): string +function openssl_decrypt(string $data, string $cipher_algo, string $passphrase, int $options = 0, string $iv = "", string $tag = null, string $aad = ""): string { error_clear_last(); - $result = \openssl_decrypt($data, $cipher_algo, $passphrase, $options, $iv, $tag, $aad); + if ($aad !== "") { + $result = \openssl_decrypt($data, $cipher_algo, $passphrase, $options, $iv, $tag, $aad); + } elseif ($tag !== null) { + $result = \openssl_decrypt($data, $cipher_algo, $passphrase, $options, $iv, $tag); + } else { + $result = \openssl_decrypt($data, $cipher_algo, $passphrase, $options, $iv); + } if ($result === false) { throw OpensslException::createFromPhpError(); } @@ -790,7 +796,7 @@ function openssl_pkcs7_decrypt(string $input_filename, string $output_filename, * @throws OpensslException * */ -function openssl_pkcs7_encrypt(string $input_filename, string $output_filename, $certificate, array $headers, int $flags = 0, int $cipher_algo = OPENSSL_CIPHER_RC2_40): void +function openssl_pkcs7_encrypt(string $input_filename, string $output_filename, $certificate, array $headers, int $flags = 0, int $cipher_algo = OPENSSL_CIPHER_AES_128_CBC): void { error_clear_last(); $result = \openssl_pkcs7_encrypt($input_filename, $output_filename, $certificate, $headers, $flags, $cipher_algo); diff --git a/generated/stream.php b/generated/stream.php index cb7f9609..3d086e14 100644 --- a/generated/stream.php +++ b/generated/stream.php @@ -24,25 +24,31 @@ function stream_context_set_params($context, array $params): void /** - * Makes a copy of up to maxlength bytes + * Makes a copy of up to length bytes * of data from the current position (or from the * offset position, if specified) in - * source to dest. If - * maxlength is not specified, all remaining content in - * source will be copied. + * from to to. If + * length is NULL, all remaining content in + * from will be copied. * - * @param resource $source The source stream - * @param resource $dest The destination stream - * @param int $maxlength Maximum bytes to copy + * @param resource $from The source stream + * @param resource $to The destination stream + * @param int $length Maximum bytes to copy. By default all bytes left are copied. * @param int $offset The offset where to start to copy data * @return int Returns the total count of bytes copied. * @throws StreamException * */ -function stream_copy_to_stream($source, $dest, int $maxlength = -1, int $offset = 0): int +function stream_copy_to_stream($from, $to, int $length = null, int $offset = 0): int { error_clear_last(); - $result = \stream_copy_to_stream($source, $dest, $maxlength, $offset); + if ($offset !== 0) { + $result = \stream_copy_to_stream($from, $to, $length, $offset); + } elseif ($length !== null) { + $result = \stream_copy_to_stream($from, $to, $length); + } else { + $result = \stream_copy_to_stream($from, $to); + } if ($result === false) { throw StreamException::createFromPhpError(); } @@ -200,11 +206,11 @@ function stream_filter_remove($stream_filter): void * Identical to file_get_contents, except that * stream_get_contents operates on an already open * stream resource and returns the remaining contents in a string, up to - * maxlength bytes and starting at the specified + * length bytes and starting at the specified * offset. * - * @param resource $handle A stream resource (e.g. returned from fopen) - * @param int $maxlength The maximum bytes to read. Defaults to -1 (read all the remaining + * @param resource $stream A stream resource (e.g. returned from fopen) + * @param int $length The maximum bytes to read. Defaults to NULL (read all the remaining * buffer). * @param int $offset Seek to the specified offset before reading. If this number is negative, * no seeking will occur and reading will start from the current position. @@ -212,10 +218,50 @@ function stream_filter_remove($stream_filter): void * @throws StreamException * */ -function stream_get_contents($handle, int $maxlength = -1, int $offset = -1): string +function stream_get_contents($stream, int $length = null, int $offset = -1): string { error_clear_last(); - $result = \stream_get_contents($handle, $maxlength, $offset); + if ($offset !== -1) { + $result = \stream_get_contents($stream, $length, $offset); + } elseif ($length !== null) { + $result = \stream_get_contents($stream, $length); + } else { + $result = \stream_get_contents($stream); + } + if ($result === false) { + throw StreamException::createFromPhpError(); + } + return $result; +} + + +/** + * Gets a line from the given handle. + * + * Reading ends when length bytes have been read, when + * the non-empty string specified by ending is found (which is + * not included in the return value), or on EOF + * (whichever comes first). + * + * This function is nearly identical to fgets except in + * that it allows end of line delimiters other than the standard \n, \r, and + * \r\n, and does not return the delimiter itself. + * + * @param resource $stream A valid file handle. + * @param int $length The maximum number of bytes to read from the handle. + * Negative values are not supported. + * Zero (0) means the default socket chunk size, + * i.e. 8192 bytes. + * @param string $ending An optional string delimiter. + * @return string Returns a string of up to length bytes read from the file + * pointed to by stream. + * @throws StreamException + * + */ +function stream_get_line($stream, int $length, string $ending = ""): string +{ + error_clear_last(); + $result = \stream_get_line($stream, $length, $ending); if ($result === false) { throw StreamException::createFromPhpError(); } @@ -317,10 +363,11 @@ function stream_set_timeout($stream, int $seconds, int $microseconds = 0): void * Accept a connection on a socket previously created by * stream_socket_server. * - * @param resource $server_socket The server socket to accept a connection from. + * @param resource $socket The server socket to accept a connection from. * @param float $timeout Override the default socket accept timeout. Time should be given in - * seconds. - * @param string|null $peername Will be set to the name (address) of the client which connected, if + * seconds. By default, default_socket_timeout + * is used. + * @param string|null $peer_name Will be set to the name (address) of the client which connected, if * included and available from the selected transport. * * Can also be determined later using @@ -329,15 +376,15 @@ function stream_set_timeout($stream, int $seconds, int $microseconds = 0): void * @throws StreamException * */ -function stream_socket_accept($server_socket, float $timeout = null, ?string &$peername = null) +function stream_socket_accept($socket, float $timeout = null, ?string &$peer_name = null) { error_clear_last(); - if ($peername !== null) { - $result = \stream_socket_accept($server_socket, $timeout, $peername); + if ($peer_name !== null) { + $result = \stream_socket_accept($socket, $timeout, $peer_name); } elseif ($timeout !== null) { - $result = \stream_socket_accept($server_socket, $timeout); + $result = \stream_socket_accept($socket, $timeout); } else { - $result = \stream_socket_accept($server_socket); + $result = \stream_socket_accept($socket); } if ($result === false) { throw StreamException::createFromPhpError(); @@ -348,20 +395,21 @@ function stream_socket_accept($server_socket, float $timeout = null, ?string &$p /** * Initiates a stream or datagram connection to the destination specified - * by remote_socket. The type of socket created + * by address. The type of socket created * is determined by the transport specified using standard URL formatting: * transport://target. For Internet Domain sockets * (AF_INET) such as TCP and UDP, the target portion - * of the remote_socket parameter should consist of + * of the address parameter should consist of * a hostname or IP address followed by a colon and a port number. For Unix * domain sockets, the target portion should point * to the socket file on the filesystem. * - * @param string $remote_socket Address to the socket to connect to. - * @param int|null $errno Will be set to the system level error number if connection fails. - * @param string|null $errstr Will be set to the system level error message if the connection fails. + * @param string $address Address to the socket to connect to. + * @param int|null $error_code Will be set to the system level error number if connection fails. + * @param string|null $error_message Will be set to the system level error message if the connection fails. * @param float $timeout Number of seconds until the connect() system call - * should timeout. + * should timeout. By default, default_socket_timeout + * is used. * * * This parameter only applies when not making asynchronous @@ -395,17 +443,17 @@ function stream_socket_accept($server_socket, float $timeout = null, ?string &$p * @throws StreamException * */ -function stream_socket_client(string $remote_socket, ?int &$errno = null, ?string &$errstr = null, float $timeout = null, int $flags = STREAM_CLIENT_CONNECT, $context = null) +function stream_socket_client(string $address, ?int &$error_code = null, ?string &$error_message = null, float $timeout = null, int $flags = STREAM_CLIENT_CONNECT, $context = null) { error_clear_last(); if ($context !== null) { - $result = \stream_socket_client($remote_socket, $errno, $errstr, $timeout, $flags, $context); + $result = \stream_socket_client($address, $error_code, $error_message, $timeout, $flags, $context); } elseif ($flags !== STREAM_CLIENT_CONNECT) { - $result = \stream_socket_client($remote_socket, $errno, $errstr, $timeout, $flags); + $result = \stream_socket_client($address, $error_code, $error_message, $timeout, $flags); } elseif ($timeout !== null) { - $result = \stream_socket_client($remote_socket, $errno, $errstr, $timeout); + $result = \stream_socket_client($address, $error_code, $error_message, $timeout); } else { - $result = \stream_socket_client($remote_socket, $errno, $errstr); + $result = \stream_socket_client($address, $error_code, $error_message); } if ($result === false) { throw StreamException::createFromPhpError(); @@ -414,6 +462,27 @@ function stream_socket_client(string $remote_socket, ?int &$errno = null, ?strin } +/** + * Returns the local or remote name of a given socket connection. + * + * @param resource $socket The socket to get the name of. + * @param bool $remote If set to TRUE the remote socket name will be returned, if set + * to FALSE the local socket name will be returned. + * @return string The name of the socket. + * @throws StreamException + * + */ +function stream_socket_get_name($socket, bool $remote): string +{ + error_clear_last(); + $result = \stream_socket_get_name($socket, $remote); + if ($result === false) { + throw StreamException::createFromPhpError(); + } + return $result; +} + + /** * stream_socket_pair creates a pair of connected, * indistinguishable socket streams. This function is commonly used in IPC @@ -448,14 +517,101 @@ function stream_socket_pair(int $domain, int $type, int $protocol): iterable } +/** + * stream_socket_recvfrom accepts + * data from a remote socket up to length bytes. + * + * @param resource $socket The remote socket. + * @param int $length The number of bytes to receive from the socket. + * @param int $flags The value of flags can be any combination + * of the following: + * + * Possible values for flags + * + * + * + * STREAM_OOB + * + * Process OOB (out-of-band) data. + * + * + * + * STREAM_PEEK + * + * Retrieve data from the socket, but do not consume the buffer. + * Subsequent calls to fread or + * stream_socket_recvfrom will see + * the same data. + * + * + * + * + * + * @param string|null $address If address is provided it will be populated with + * the address of the remote socket. + * @return string Returns the read data, as a string. + * @throws StreamException + * + */ +function stream_socket_recvfrom($socket, int $length, int $flags = 0, ?string &$address = null): string +{ + error_clear_last(); + $result = \stream_socket_recvfrom($socket, $length, $flags, $address); + if ($result === false) { + throw StreamException::createFromPhpError(); + } + return $result; +} + + +/** + * Sends the specified data through the + * socket. + * + * @param resource $socket The socket to send data to. + * @param string $data The data to be sent. + * @param int $flags The value of flags can be any combination + * of the following: + * + * possible values for flags + * + * + * + * STREAM_OOB + * + * Process OOB (out-of-band) data. + * + * + * + * + * + * @param string $address The address specified when the socket stream was created will be used + * unless an alternate address is specified in address. + * + * If specified, it must be in dotted quad (or [ipv6]) format. + * @return int Returns a result code, as an integer. + * @throws StreamException + * + */ +function stream_socket_sendto($socket, string $data, int $flags = 0, string $address = ""): int +{ + error_clear_last(); + $result = \stream_socket_sendto($socket, $data, $flags, $address); + if ($result === false) { + throw StreamException::createFromPhpError(); + } + return $result; +} + + /** * Creates a stream or datagram socket on the specified - * local_socket. + * address. * * This function only creates a socket, to begin accepting connections * use stream_socket_accept. * - * @param string $local_socket The type of socket created is determined by the transport specified + * @param string $address The type of socket created is determined by the transport specified * using standard URL formatting: transport://target. * * For Internet Domain sockets (AF_INET) such as TCP and UDP, the @@ -469,17 +625,17 @@ function stream_socket_pair(int $domain, int $type, int $protocol): iterable * A list of available transports can be retrieved using * stream_get_transports. See * for a list of bulitin transports. - * @param int|null $errno If the optional errno and errstr + * @param int|null $error_code If the optional error_code and error_message * arguments are present they will be set to indicate the actual system * level error that occurred in the system-level socket(), * bind(), and listen() calls. If - * the value returned in errno is + * the value returned in error_code is * 0 and the function returned FALSE, it is an * indication that the error occurred before the bind() * call. This is most likely due to a problem initializing the socket. - * Note that the errno and - * errstr arguments will always be passed by reference. - * @param string|null $errstr See errno description. + * Note that the error_code and + * error_message arguments will always be passed by reference. + * @param string|null $error_message See error_code description. * @param int $flags A bitmask field which may be set to any combination of socket creation * flags. * @@ -490,13 +646,13 @@ function stream_socket_pair(int $domain, int $type, int $protocol): iterable * @throws StreamException * */ -function stream_socket_server(string $local_socket, ?int &$errno = null, ?string &$errstr = null, int $flags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN, $context = null) +function stream_socket_server(string $address, ?int &$error_code = null, ?string &$error_message = null, int $flags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN, $context = null) { error_clear_last(); if ($context !== null) { - $result = \stream_socket_server($local_socket, $errno, $errstr, $flags, $context); + $result = \stream_socket_server($address, $error_code, $error_message, $flags, $context); } else { - $result = \stream_socket_server($local_socket, $errno, $errstr, $flags); + $result = \stream_socket_server($address, $error_code, $error_message, $flags); } if ($result === false) { throw StreamException::createFromPhpError(); diff --git a/generated/zlib.php b/generated/zlib.php index db416aa3..39dc8985 100644 --- a/generated/zlib.php +++ b/generated/zlib.php @@ -346,12 +346,12 @@ function gzgetss($zp, int $length, string $allowable_tags = null): string * This function inflates a deflated string. * * @param string $data The data compressed by gzdeflate. - * @param int $max_length The maximum length of data to decode. + * @param int $max_length The maximum length of decoded data. * @return string The original uncompressed data. * * The function will return an error if the uncompressed data is more than * 32768 times the length of the compressed input data - * or more than the optional parameter max_length. + * or, unless max_length is 0, more than the optional parameter max_length. * @throws ZlibException * */ diff --git a/generator/tests/DocPageTest.php b/generator/tests/DocPageTest.php index c1c88f2c..5f449c41 100644 --- a/generator/tests/DocPageTest.php +++ b/generator/tests/DocPageTest.php @@ -41,11 +41,9 @@ public function testDetectFalsyFunction() public function testDetectNullsyFunction() { - $pregMatch = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/array/functions/array-flip.xml'); $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->assertTrue($pregMatch->detectNullsyFunction()); $this->assertFalse($implode->detectNullsyFunction()); $this->assertTrue($arrayReplace->detectNullsyFunction()); } diff --git a/rector-migrate.php b/rector-migrate.php index 7420c7f3..45af36a9 100644 --- a/rector-migrate.php +++ b/rector-migrate.php @@ -25,7 +25,6 @@ 'apcu_sma_info' => 'Safe\apcu_sma_info', 'apc_fetch' => 'Safe\apc_fetch', 'array_combine' => 'Safe\array_combine', - 'array_flip' => 'Safe\array_flip', 'array_replace' => 'Safe\array_replace', 'array_replace_recursive' => 'Safe\array_replace_recursive', 'array_walk_recursive' => 'Safe\array_walk_recursive', @@ -191,6 +190,7 @@ 'fclose' => 'Safe\fclose', 'fdatasync' => 'Safe\fdatasync', 'fflush' => 'Safe\fflush', + 'fgetcsv' => 'Safe\fgetcsv', 'file' => 'Safe\file', 'fileatime' => 'Safe\fileatime', 'filectime' => 'Safe\filectime', @@ -231,6 +231,7 @@ 'ftp_pasv' => 'Safe\ftp_pasv', 'ftp_put' => 'Safe\ftp_put', 'ftp_pwd' => 'Safe\ftp_pwd', + 'ftp_raw' => 'Safe\ftp_raw', 'ftp_rename' => 'Safe\ftp_rename', 'ftp_rmdir' => 'Safe\ftp_rmdir', 'ftp_site' => 'Safe\ftp_site', @@ -331,7 +332,6 @@ 'imagecolordeallocate' => 'Safe\imagecolordeallocate', 'imagecolormatch' => 'Safe\imagecolormatch', 'imagecolorset' => 'Safe\imagecolorset', - 'imagecolorsforindex' => 'Safe\imagecolorsforindex', 'imageconvolution' => 'Safe\imageconvolution', 'imagecopy' => 'Safe\imagecopy', 'imagecopymerge' => 'Safe\imagecopymerge', @@ -539,7 +539,6 @@ 'msg_send' => 'Safe\msg_send', 'msg_set_queue' => 'Safe\msg_set_queue', 'msg_stat_queue' => 'Safe\msg_stat_queue', - 'mysqli_get_client_stats' => 'Safe\mysqli_get_client_stats', 'mysql_close' => 'Safe\mysql_close', 'mysql_connect' => 'Safe\mysql_connect', 'mysql_create_db' => 'Safe\mysql_create_db', @@ -571,6 +570,7 @@ 'mysql_tablename' => 'Safe\mysql_tablename', 'mysql_thread_id' => 'Safe\mysql_thread_id', 'mysql_unbuffered_query' => 'Safe\mysql_unbuffered_query', + 'net_get_interfaces' => 'Safe\net_get_interfaces', 'ob_clean' => 'Safe\ob_clean', 'ob_end_clean' => 'Safe\ob_end_clean', 'ob_end_flush' => 'Safe\ob_end_flush', @@ -610,6 +610,7 @@ 'oci_set_edition' => 'Safe\oci_set_edition', 'oci_set_module_name' => 'Safe\oci_set_module_name', 'oci_set_prefetch' => 'Safe\oci_set_prefetch', + 'oci_set_prefetch_lob' => 'Safe\oci_set_prefetch_lob', 'oci_statement_type' => 'Safe\oci_statement_type', 'oci_unregister_taf_callback' => 'Safe\oci_unregister_taf_callback', 'odbc_autocommit' => 'Safe\odbc_autocommit', @@ -1017,13 +1018,17 @@ 'stream_filter_register' => 'Safe\stream_filter_register', 'stream_filter_remove' => 'Safe\stream_filter_remove', 'stream_get_contents' => 'Safe\stream_get_contents', + 'stream_get_line' => 'Safe\stream_get_line', 'stream_isatty' => 'Safe\stream_isatty', 'stream_resolve_include_path' => 'Safe\stream_resolve_include_path', 'stream_set_blocking' => 'Safe\stream_set_blocking', 'stream_set_timeout' => 'Safe\stream_set_timeout', 'stream_socket_accept' => 'Safe\stream_socket_accept', 'stream_socket_client' => 'Safe\stream_socket_client', + 'stream_socket_get_name' => 'Safe\stream_socket_get_name', 'stream_socket_pair' => 'Safe\stream_socket_pair', + 'stream_socket_recvfrom' => 'Safe\stream_socket_recvfrom', + 'stream_socket_sendto' => 'Safe\stream_socket_sendto', 'stream_socket_server' => 'Safe\stream_socket_server', 'stream_socket_shutdown' => 'Safe\stream_socket_shutdown', 'stream_supports_lock' => 'Safe\stream_supports_lock',