From e19610c7bb1f829bf0886f5a94a21924141212de Mon Sep 17 00:00:00 2001 From: Michael Moll Date: Tue, 1 Feb 2022 22:08:44 +0100 Subject: [PATCH] bring in curl handles (#322) see https://php.watch/versions/8.0/resource-CurlHandle --- generated/curl.php | 46 +++++++++---------- generator/config/CustomPhpStanFunctionMap.php | 11 +++++ 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/generated/curl.php b/generated/curl.php index 0a7a516b..a85379a6 100644 --- a/generated/curl.php +++ b/generated/curl.php @@ -7,13 +7,13 @@ /** * Copies a cURL handle keeping the same preferences. * - * @param resource $handle A cURL handle returned by + * @param \CurlHandle $handle A cURL handle returned by * curl_init. - * @return resource Returns a new cURL handle. + * @return \CurlHandle Returns a new cURL handle. * @throws CurlException * */ -function curl_copy_handle($handle) +function curl_copy_handle(\CurlHandle $handle): \CurlHandle { error_clear_last(); $result = \curl_copy_handle($handle); @@ -27,14 +27,14 @@ function curl_copy_handle($handle) /** * This function URL encodes the given string according to RFC 3986. * - * @param resource $handle A cURL handle returned by + * @param \CurlHandle $handle A cURL handle returned by * curl_init. * @param string $string The string to be encoded. * @return string Returns escaped string. * @throws CurlException * */ -function curl_escape($handle, string $string): string +function curl_escape(\CurlHandle $handle, string $string): string { error_clear_last(); $result = \curl_escape($handle, $string); @@ -51,7 +51,7 @@ function curl_escape($handle, string $string): string * This function should be called after initializing a cURL session and all * the options for the session are set. * - * @param resource $handle 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 @@ -59,7 +59,7 @@ function curl_escape($handle, string $string): string * @throws CurlException * */ -function curl_exec($handle) +function curl_exec(\CurlHandle $handle) { error_clear_last(); $result = \curl_exec($handle); @@ -73,7 +73,7 @@ function curl_exec($handle) /** * Gets information about the last transfer. * - * @param resource $handle A cURL handle returned by + * @param \CurlHandle $handle A cURL handle returned by * curl_init. * @param int $option This may be one of the following constants: * @@ -532,7 +532,7 @@ function curl_exec($handle) * @throws CurlException * */ -function curl_getinfo($handle, int $option = null) +function curl_getinfo(\CurlHandle $handle, int $option = null) { error_clear_last(); if ($option !== null) { @@ -587,7 +587,7 @@ function curl_init(string $url = null): \CurlHandle * queued_messages will contain the number of remaining messages after this * function was called. * - * @param resource $multi_handle A cURL multi handle returned by + * @param \CurlMultiHandle $multi_handle A cURL multi handle returned by * curl_multi_init. * @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. @@ -622,7 +622,7 @@ function curl_init(string $url = null): \CurlHandle * @throws CurlException * */ -function curl_multi_info_read($multi_handle, ?int &$queued_messages = null): array +function curl_multi_info_read(\CurlMultiHandle $multi_handle, ?int &$queued_messages = null): array { error_clear_last(); $result = \curl_multi_info_read($multi_handle, $queued_messages); @@ -636,11 +636,11 @@ function curl_multi_info_read($multi_handle, ?int &$queued_messages = null): arr /** * Allows the processing of multiple cURL handles asynchronously. * - * @return resource Returns a cURL multi handle 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(); @@ -654,7 +654,7 @@ function curl_multi_init() /** * * - * @param resource $multi_handle + * @param \CurlMultiHandle $multi_handle * @param int $option One of the CURLMOPT_* constants. * @param mixed $value The value to be set on option. * @@ -786,7 +786,7 @@ function curl_multi_init() * @throws CurlException * */ -function curl_multi_setopt($multi_handle, int $option, $value): void +function curl_multi_setopt(\CurlMultiHandle $multi_handle, int $option, $value): void { error_clear_last(); $result = \curl_multi_setopt($multi_handle, $option, $value); @@ -799,7 +799,7 @@ function curl_multi_setopt($multi_handle, int $option, $value): void /** * Sets an option on the given cURL session handle. * - * @param resource $handle 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. @@ -3137,7 +3137,7 @@ function curl_multi_setopt($multi_handle, int $option, $value): void * @throws CurlException * */ -function curl_setopt($handle, int $option, $value): void +function curl_setopt(\CurlHandle $handle, int $option, $value): void { error_clear_last(); $result = \curl_setopt($handle, $option, $value); @@ -3150,13 +3150,13 @@ function curl_setopt($handle, int $option, $value): void /** * Return an integer containing the last share curl error number. * - * @param resource $share_handle A cURL share handle returned by + * @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($share_handle): int +function curl_share_errno(\CurlShareHandle $share_handle): int { error_clear_last(); $result = \curl_share_errno($share_handle); @@ -3170,7 +3170,7 @@ function curl_share_errno($share_handle): int /** * Sets an option on the given cURL share handle. * - * @param resource $share_handle A cURL share handle returned by + * @param \CurlShareHandle $share_handle A cURL share handle returned by * curl_share_init. * @param int $option * @@ -3233,7 +3233,7 @@ function curl_share_errno($share_handle): int * @throws CurlException * */ -function curl_share_setopt($share_handle, int $option, $value): void +function curl_share_setopt(\CurlShareHandle $share_handle, int $option, $value): void { error_clear_last(); $result = \curl_share_setopt($share_handle, $option, $value); @@ -3246,14 +3246,14 @@ function curl_share_setopt($share_handle, int $option, $value): void /** * This function decodes the given URL encoded string. * - * @param resource $handle A cURL handle returned by + * @param \CurlHandle $handle A cURL handle returned by * curl_init. * @param string $string The URL encoded string to be decoded. * @return string Returns decoded string. * @throws CurlException * */ -function curl_unescape($handle, string $string): string +function curl_unescape(\CurlHandle $handle, string $string): string { error_clear_last(); $result = \curl_unescape($handle, $string); diff --git a/generator/config/CustomPhpStanFunctionMap.php b/generator/config/CustomPhpStanFunctionMap.php index 87ad7b3f..923ca7fa 100644 --- a/generator/config/CustomPhpStanFunctionMap.php +++ b/generator/config/CustomPhpStanFunctionMap.php @@ -15,4 +15,15 @@ 'get_headers' => ['array|false', 'url'=>'string', 'format='=>'bool', 'context='=>'resource'], // format is a bool instead of int 'imagegrabwindow' => ['GdImage|false', 'handle'=>'int', 'client_area'=>'bool'], // client_ara is a bool instead of an int 'curl_init' => ['CurlHandle|false', 'url'=>'string'], // the return value is a CurlHandle instead of a resource + 'curl_copy_handle' => ['CurlHandle', 'handle' => 'CurlHandle'], + 'curl_escape' => ['string', 'handle' => 'CurlHandle', 'string' => 'string'], + 'curl_exec' => ['bool|string', 'handle' => 'CurlHandle'], + 'curl_getinfo' => ['mixed', 'handle' => 'CurlHandle', 'option' => 'int'], + 'curl_multi_info_read' => ['array', 'multi_handle' => 'CurlMultiHandle', 'queued_messages' => 'int|null'], + 'curl_multi_init' => ['CurlMultiHandle'], + 'curl_multi_setopt' => ['void', 'multi_handle' => 'CurlMultiHandle', 'option' => 'int', 'value' => 'mixed'], + 'curl_setopt' => ['void', 'handle' => 'CurlHandle', 'option' => 'int', 'value' => 'mixed'], + 'curl_share_errno' => ['int', 'share_handle' => 'CurlShareHandle'], + 'curl_share_setopt' => ['void', 'share_handle' => 'CurlShareHandle', 'option' => 'int', 'value' => 'mixed'], + 'curl_unescape' => ['string', 'handle' => 'CurlHandle', 'string' => 'string'], ];