diff options
Diffstat (limited to 'vendor/thecodingmachine/safe/generated/curl.php')
-rw-r--r-- | vendor/thecodingmachine/safe/generated/curl.php | 410 |
1 files changed, 259 insertions, 151 deletions
diff --git a/vendor/thecodingmachine/safe/generated/curl.php b/vendor/thecodingmachine/safe/generated/curl.php index 53f925536..a85379a63 100644 --- a/vendor/thecodingmachine/safe/generated/curl.php +++ b/vendor/thecodingmachine/safe/generated/curl.php @@ -5,21 +5,41 @@ namespace Safe; use Safe\Exceptions\CurlException; /** + * Copies a cURL handle keeping the same preferences. + * + * @param \CurlHandle $handle A cURL handle returned by + * curl_init. + * @return \CurlHandle Returns a new cURL handle. + * @throws CurlException + * + */ +function curl_copy_handle(\CurlHandle $handle): \CurlHandle +{ + error_clear_last(); + $result = \curl_copy_handle($handle); + if ($result === false) { + throw CurlException::createFromPhpError(); + } + return $result; +} + + +/** * This function URL encodes the given string according to RFC 3986. * - * @param resource $ch A cURL handle returned by + * @param \CurlHandle $handle A cURL handle returned by * curl_init. - * @param string $str The string to be encoded. + * @param string $string The string to be encoded. * @return string Returns escaped string. * @throws CurlException * */ -function curl_escape($ch, string $str): string +function curl_escape(\CurlHandle $handle, string $string): string { error_clear_last(); - $result = \curl_escape($ch, $str); + $result = \curl_escape($handle, $string); if ($result === false) { - throw CurlException::createFromCurlResource($ch); + throw CurlException::createFromPhpError(); } return $result; } @@ -31,7 +51,7 @@ function curl_escape($ch, string $str): string * This function should be called after initializing a cURL session and all * the options for the session are set. * - * @param resource $ch A cURL handle returned by + * @param \CurlHandle $handle A cURL handle returned by * curl_init. * @return bool|string Returns TRUE on success. However, if the CURLOPT_RETURNTRANSFER * option is set, it will return @@ -39,12 +59,12 @@ function curl_escape($ch, string $str): string * @throws CurlException * */ -function curl_exec($ch) +function curl_exec(\CurlHandle $handle) { error_clear_last(); - $result = \curl_exec($ch); + $result = \curl_exec($handle); if ($result === false) { - throw CurlException::createFromCurlResource($ch); + throw CurlException::createFromPhpError(); } return $result; } @@ -53,9 +73,9 @@ function curl_exec($ch) /** * Gets information about the last transfer. * - * @param resource $ch A cURL handle returned by + * @param \CurlHandle $handle A cURL handle returned by * curl_init. - * @param int $opt This may be one of the following constants: + * @param int $option This may be one of the following constants: * * * @@ -65,7 +85,7 @@ function curl_exec($ch) * * * CURLINFO_HTTP_CODE - The last response code. - * As of PHP 5.5.0 and cURL 7.10.8, this is a legacy alias of + * As of cURL 7.10.8, this is a legacy alias of * CURLINFO_RESPONSE_CODE * * @@ -367,9 +387,9 @@ function curl_exec($ch) * * * - * @return mixed If opt is given, returns its value. + * @return mixed If option is given, returns its value. * Otherwise, returns an associative array with the following elements - * (which correspond to opt): + * (which correspond to option): * * * @@ -512,16 +532,16 @@ function curl_exec($ch) * @throws CurlException * */ -function curl_getinfo($ch, int $opt = null) +function curl_getinfo(\CurlHandle $handle, int $option = null) { error_clear_last(); - if ($opt !== null) { - $result = \curl_getinfo($ch, $opt); + if ($option !== null) { + $result = \curl_getinfo($handle, $option); } else { - $result = \curl_getinfo($ch); + $result = \curl_getinfo($handle); } if ($result === false) { - throw CurlException::createFromCurlResource($ch); + throw CurlException::createFromPhpError(); } return $result; } @@ -538,34 +558,18 @@ function curl_getinfo($ch, int $opt = null) * * The file protocol is disabled by cURL if * open_basedir is set. - * @return resource Returns a cURL handle on success, FALSE on errors. + * @return \CurlHandle Returns a cURL handle on success, FALSE on errors. * @throws CurlException * */ -function curl_init(string $url = null) +function curl_init(string $url = null): \CurlHandle { error_clear_last(); - $result = \curl_init($url); - if ($result === false) { - throw CurlException::createFromPhpError(); + if ($url !== null) { + $result = \curl_init($url); + } else { + $result = \curl_init(); } - return $result; -} - - -/** - * Return an integer containing the last multi curl error number. - * - * @param resource $mh A cURL multi handle returned by - * curl_multi_init. - * @return int Return an integer containing the last multi curl error number. - * @throws CurlException - * - */ -function curl_multi_errno($mh): int -{ - error_clear_last(); - $result = \curl_multi_errno($mh); if ($result === false) { throw CurlException::createFromPhpError(); } @@ -580,12 +584,12 @@ function curl_multi_errno($mh): int * * Repeated calls to this function will return a new result each time, until a FALSE is returned * as a signal that there is no more to get at this point. The integer pointed to with - * msgs_in_queue will contain the number of remaining messages after this + * queued_messages will contain the number of remaining messages after this * function was called. * - * @param resource $mh A cURL multi handle returned by + * @param \CurlMultiHandle $multi_handle A cURL multi handle returned by * curl_multi_init. - * @param int|null $msgs_in_queue Number of messages that are still in the queue + * @param int|null $queued_messages Number of messages that are still in the queue * @return array On success, returns an associative array for the message, FALSE on failure. * * @@ -618,10 +622,10 @@ function curl_multi_errno($mh): int * @throws CurlException * */ -function curl_multi_info_read($mh, ?int &$msgs_in_queue = null): array +function curl_multi_info_read(\CurlMultiHandle $multi_handle, ?int &$queued_messages = null): array { error_clear_last(); - $result = \curl_multi_info_read($mh, $msgs_in_queue); + $result = \curl_multi_info_read($multi_handle, $queued_messages); if ($result === false) { throw CurlException::createFromPhpError(); } @@ -632,11 +636,11 @@ function curl_multi_info_read($mh, ?int &$msgs_in_queue = null): array /** * Allows the processing of multiple cURL handles asynchronously. * - * @return resource Returns a cURL multi handle resource on success, FALSE on failure. + * @return \CurlMultiHandle Returns a cURL multi handle on success, FALSE on failure. * @throws CurlException * */ -function curl_multi_init() +function curl_multi_init(): \CurlMultiHandle { error_clear_last(); $result = \curl_multi_init(); @@ -648,9 +652,154 @@ function curl_multi_init() /** + * + * + * @param \CurlMultiHandle $multi_handle + * @param int $option One of the CURLMOPT_* constants. + * @param mixed $value The value to be set on option. + * + * value should be an int for the + * following values of the option parameter: + * + * + * + * + * Option + * Set value to + * + * + * + * + * CURLMOPT_PIPELINING + * + * Pass 1 to enable or 0 to disable. Enabling pipelining on a multi + * handle will make it attempt to perform HTTP Pipelining as far as + * possible for transfers using this handle. This means that if you add + * a second request that can use an already existing connection, the + * second request will be "piped" on the same connection. + * As of cURL 7.43.0, the value is a bitmask, and you can also pass 2 to try to multiplex the new + * transfer over an existing HTTP/2 connection if possible. + * Passing 3 instructs cURL to ask for pipelining and multiplexing + * independently of each other. + * As of cURL 7.62.0, setting the pipelining bit has no effect. + * Instead of integer literals, you can also use the CURLPIPE_* + * constants if available. + * + * + * + * CURLMOPT_MAXCONNECTS + * + * Pass a number that will be used as the maximum amount of + * simultaneously open connections that libcurl may cache. + * By default the size will be enlarged to fit four times the number + * of handles added via curl_multi_add_handle. + * When the cache is full, curl closes the oldest one in the cache + * to prevent the number of open connections from increasing. + * + * + * + * CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE + * + * Pass a number that specifies the chunk length threshold for pipelining + * in bytes. + * + * + * + * CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE + * + * Pass a number that specifies the size threshold for pipelining + * penalty in bytes. + * + * + * + * CURLMOPT_MAX_HOST_CONNECTIONS + * + * Pass a number that specifies the maximum number of connections to a + * single host. + * + * + * + * CURLMOPT_MAX_PIPELINE_LENGTH + * + * Pass a number that specifies the maximum number of requests in a + * pipeline. + * + * + * + * CURLMOPT_MAX_TOTAL_CONNECTIONS + * + * Pass a number that specifies the maximum number of simultaneously + * open connections. + * + * + * + * CURLMOPT_PUSHFUNCTION + * + * Pass a callable that will be registered to handle server + * pushes and should have the following signature: + * + * intpushfunction + * resourceparent_ch + * resourcepushed_ch + * arrayheaders + * + * + * + * parent_ch + * + * + * The parent cURL handle (the request the client made). + * + * + * + * + * pushed_ch + * + * + * A new cURL handle for the pushed request. + * + * + * + * + * headers + * + * + * The push promise headers. + * + * + * + * + * The push function is supposed to return either + * CURL_PUSH_OK if it can handle the push, or + * CURL_PUSH_DENY to reject it. + * + * + * + * + * + * + * The parent cURL handle (the request the client made). + * + * A new cURL handle for the pushed request. + * + * The push promise headers. + * @throws CurlException + * + */ +function curl_multi_setopt(\CurlMultiHandle $multi_handle, int $option, $value): void +{ + error_clear_last(); + $result = \curl_multi_setopt($multi_handle, $option, $value); + if ($result === false) { + throw CurlException::createFromPhpError(); + } +} + + +/** * Sets an option on the given cURL session handle. * - * @param resource $ch A cURL handle returned by + * @param \CurlHandle $handle A cURL handle returned by * curl_init. * @param int $option The CURLOPT_XXX option to set. * @param mixed $value The value to be set on option. @@ -677,18 +826,6 @@ function curl_multi_init() * * * - * CURLOPT_BINARYTRANSFER - * - * TRUE to return the raw output when - * CURLOPT_RETURNTRANSFER is used. - * - * - * From PHP 5.1.3, this option has no effect: the raw output will - * always be returned when - * CURLOPT_RETURNTRANSFER is used. - * - * - * * CURLOPT_COOKIESESSION * * TRUE to mark this as a new cookie "session". It will force libcurl @@ -709,7 +846,6 @@ function curl_multi_init() * * * Added in cURL 7.19.1. - * Available since PHP 5.3.2. * Requires CURLOPT_VERBOSE to be on to have an effect. * * @@ -722,7 +858,6 @@ function curl_multi_init() * * * Added in 7.15.2. - * Available since PHP 5.5.0. * * * @@ -819,9 +954,8 @@ function curl_multi_init() * * TRUE to follow any * "Location: " header that the server sends as - * part of the HTTP header (note this is recursive, PHP will follow as - * many "Location: " headers that it is sent, - * unless CURLOPT_MAXREDIRS is set). + * part of the HTTP header. + * See also CURLOPT_MAXREDIRS. * * * @@ -889,7 +1023,7 @@ function curl_multi_init() * the number of small packets on the network. * * - * Available since PHP 5.2.1 for versions compiled with libcurl 7.11.2 or + * Available for versions compiled with libcurl 7.11.2 or * greater. * * @@ -925,7 +1059,7 @@ function curl_multi_init() * TRUE to track the handle's request string. * * - * Available since PHP 5.1.3. The CURLINFO_ + * The CURLINFO_ * prefix is intentional. * * @@ -963,7 +1097,7 @@ function curl_multi_init() * FALSE to get the raw HTTP response body. * * - * Available as of PHP 5.5.0 if built against libcurl >= 7.16.2. + * Available if built against libcurl >= 7.16.2. * * * @@ -1082,21 +1216,6 @@ function curl_multi_init() * * * - * CURLOPT_SAFE_UPLOAD - * - * TRUE to disable support for the @ prefix for - * uploading files in CURLOPT_POSTFIELDS, which - * means that values starting with @ can be safely - * passed as fields. CURLFile may be used for - * uploads instead. - * - * - * Added in PHP 5.5.0 with FALSE as the default value. PHP 5.6.0 - * changes the default value to TRUE. PHP 7 removes this option; - * the CURLFile interface must be used to upload files. - * - * - * * CURLOPT_SASL_IR * * TRUE to enable sending the initial response in the first packet. @@ -1248,7 +1367,7 @@ function curl_multi_init() * PHP automatically sets this option to TRUE, this should only be * changed for debugging purposes. * - * value should be an integer for the + * value should be an int for the * following values of the option parameter: * * @@ -1271,21 +1390,6 @@ function curl_multi_init() * * * - * CURLOPT_CLOSEPOLICY - * - * One of the CURLCLOSEPOLICY_* values. - * - * - * This option is deprecated, as it was never implemented in cURL and - * never had any effect. - * - * - * - * - * Removed in PHP 5.6.0. - * - * - * * CURLOPT_CONNECTTIMEOUT * * The number of seconds to wait while trying to connect. Use 0 to @@ -1305,7 +1409,7 @@ function curl_multi_init() * timeouts with a minimum timeout allowed of one second. * * - * Added in cURL 7.16.2. Available since PHP 5.2.3. + * Added in cURL 7.16.2. * * * @@ -1472,6 +1576,9 @@ function curl_multi_init() * * The maximum amount of HTTP redirections to follow. Use this option * alongside CURLOPT_FOLLOWLOCATION. + * Default value of 20 is set to prevent infinite redirects. + * Setting to -1 allows inifinite redirects, and 0 + * refuses all redirects. * * * @@ -1493,7 +1600,7 @@ function curl_multi_init() * specific type of redirect occurs. * * - * Added in cURL 7.19.1. Available since PHP 5.3.2. + * Added in cURL 7.19.1. * * * @@ -1640,10 +1747,11 @@ function curl_multi_init() * * CURLOPT_SSL_VERIFYHOST * - * 1 to check the existence of a common name in the - * SSL peer certificate. 2 to check the existence of - * a common name and also verify that it matches the hostname - * provided. 0 to not check the names. In production environments the value of this option + * 2 to verify that a Common Name field or a Subject Alternate Name + * field in the SSL peer certificate matches the provided hostname. + * 0 to not check the names. + * 1 should not be used. + * In production environments the value of this option * should be kept at 2 (default value). * * @@ -1760,7 +1868,7 @@ function curl_multi_init() * supports them. If set to 0 (default) keepalive probes are disabled. * * - * Added in cURL 7.25.0. Available since PHP 5.5.0. + * Added in cURL 7.25.0. * * * @@ -1772,7 +1880,7 @@ function curl_multi_init() * The default is 60. * * - * Added in cURL 7.25.0. Available since PHP 5.5.0. + * Added in cURL 7.25.0. * * * @@ -1784,7 +1892,7 @@ function curl_multi_init() * The default is 60. * * - * Added in cURL 7.25.0. Available since PHP 5.5.0. + * Added in cURL 7.25.0. * * * @@ -1797,10 +1905,13 @@ function curl_multi_init() * a "304 Not Modified" header will be returned * assuming CURLOPT_HEADER is TRUE. * Use CURL_TIMECOND_IFUNMODSINCE for the reverse - * effect. CURL_TIMECOND_IFMODSINCE is the - * default. + * effect. Use CURL_TIMECOND_NONE to ignore + * CURLOPT_TIMEVALUE and always return the page. + * CURL_TIMECOND_NONE is the default. * * + * Before cURL 7.46.0 the default was + * CURL_TIMECOND_IFMODSINCE. * * * @@ -1822,15 +1933,14 @@ function curl_multi_init() * timeouts with a minimum timeout allowed of one second. * * - * Added in cURL 7.16.2. Available since PHP 5.2.3. + * Added in cURL 7.16.2. * * * * CURLOPT_TIMEVALUE * * The time in seconds since January 1st, 1970. The time will be used - * by CURLOPT_TIMECONDITION. By default, - * CURL_TIMECOND_IFMODSINCE is used. + * by CURLOPT_TIMECONDITION. * * * @@ -1857,7 +1967,7 @@ function curl_multi_init() * Defaults to unlimited speed. * * - * Added in cURL 7.15.5. Available since PHP 5.4.0. + * Added in cURL 7.15.5. * * * @@ -1869,7 +1979,7 @@ function curl_multi_init() * Defaults to unlimited speed. * * - * Added in cURL 7.15.5. Available since PHP 5.4.0. + * Added in cURL 7.15.5. * * * @@ -1910,15 +2020,12 @@ function curl_multi_init() * CURLFTPMETHOD_SINGLECWD. * * - * Added in cURL 7.15.1. Available since PHP 5.3.0. - * + * Added in cURL 7.15.1. * * * * * - * This option is deprecated, as it was never implemented in cURL and - * never had any effect. * * The HTTP authentication method(s) to use. The options are: * CURLAUTH_BASIC, @@ -2074,7 +2181,7 @@ function curl_multi_init() * "RELOAD" loads all cookies from the files specified by CURLOPT_COOKIEFILE. * * - * Available since PHP 5.5.0 and cURL 7.14.1. + * Available since cURL 7.14.1. * * * @@ -2239,10 +2346,7 @@ function curl_multi_init() * * * The full data to post in a HTTP "POST" operation. - * To post a file, prepend a filename with @ and - * use the full path. The filetype can be explicitly specified by - * following the filename with the type in the format - * ';type=mimetype'. This parameter can either be + * This parameter can either be * passed as a urlencoded string like 'para1=val1&para2=val2&...' * or as an array with the field name as key and field data as value. * If value is an array, the @@ -2250,15 +2354,8 @@ function curl_multi_init() * multipart/form-data. * * - * As of PHP 5.2.0, value must be an array if - * files are passed to this option with the @ prefix. - * - * - * As of PHP 5.5.0, the @ prefix is deprecated and - * files can be sent using CURLFile. The - * @ prefix can be disabled for safe passing of - * values beginning with @ by setting the - * CURLOPT_SAFE_UPLOAD option to TRUE. + * Files can be sent using CURLFile or CURLStringFile, + * in which case value must be an array. * * * @@ -2709,7 +2806,16 @@ function curl_multi_init() * The user name to use in authentication. * * - * Added in cURL 7.19.1. Available since PHP 5.5.0. + * Added in cURL 7.19.1. + * + * + * + * CURLOPT_PASSWORD + * + * The password to use in authentication. + * + * + * Added in cURL 7.19.1. * * * @@ -2864,7 +2970,7 @@ function curl_multi_init() * * * - * Added in cURL 7.21.3. Available since PHP 5.5.0. + * Added in cURL 7.21.3. * * * @@ -3031,12 +3137,12 @@ function curl_multi_init() * @throws CurlException * */ -function curl_setopt($ch, int $option, $value): void +function curl_setopt(\CurlHandle $handle, int $option, $value): void { error_clear_last(); - $result = \curl_setopt($ch, $option, $value); + $result = \curl_setopt($handle, $option, $value); if ($result === false) { - throw CurlException::createFromCurlResource($ch); + throw CurlException::createFromPhpError(); } } @@ -3044,15 +3150,16 @@ function curl_setopt($ch, int $option, $value): void /** * Return an integer containing the last share curl error number. * - * @param resource $sh A cURL share handle returned by curl_share_init. + * @param \CurlShareHandle $share_handle A cURL share handle returned by + * curl_share_init. * @return int Returns an integer containing the last share curl error number. * @throws CurlException * */ -function curl_share_errno($sh): int +function curl_share_errno(\CurlShareHandle $share_handle): int { error_clear_last(); - $result = \curl_share_errno($sh); + $result = \curl_share_errno($share_handle); if ($result === false) { throw CurlException::createFromPhpError(); } @@ -3063,7 +3170,8 @@ function curl_share_errno($sh): int /** * Sets an option on the given cURL share handle. * - * @param resource $sh A cURL share handle returned by curl_share_init. + * @param \CurlShareHandle $share_handle A cURL share handle returned by + * curl_share_init. * @param int $option * * @@ -3088,7 +3196,7 @@ function curl_share_errno($sh): int * * * - * @param string $value + * @param mixed $value * * * @@ -3125,10 +3233,10 @@ function curl_share_errno($sh): int * @throws CurlException * */ -function curl_share_setopt($sh, int $option, string $value): void +function curl_share_setopt(\CurlShareHandle $share_handle, int $option, $value): void { error_clear_last(); - $result = \curl_share_setopt($sh, $option, $value); + $result = \curl_share_setopt($share_handle, $option, $value); if ($result === false) { throw CurlException::createFromPhpError(); } @@ -3138,19 +3246,19 @@ function curl_share_setopt($sh, int $option, string $value): void /** * This function decodes the given URL encoded string. * - * @param resource $ch A cURL handle returned by + * @param \CurlHandle $handle A cURL handle returned by * curl_init. - * @param string $str The URL encoded string to be decoded. + * @param string $string The URL encoded string to be decoded. * @return string Returns decoded string. * @throws CurlException * */ -function curl_unescape($ch, string $str): string +function curl_unescape(\CurlHandle $handle, string $string): string { error_clear_last(); - $result = \curl_unescape($ch, $str); + $result = \curl_unescape($handle, $string); if ($result === false) { - throw CurlException::createFromCurlResource($ch); + throw CurlException::createFromPhpError(); } return $result; } |