Skip to content

Commit

Permalink
bring in curl handles (#322)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoll committed Feb 1, 2022
1 parent c11fc2e commit e19610c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 23 deletions.
46 changes: 23 additions & 23 deletions generated/curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -51,15 +51,15 @@ 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
* the result on success, FALSE on failure.
* @throws CurlException
*
*/
function curl_exec($handle)
function curl_exec(\CurlHandle $handle)
{
error_clear_last();
$result = \curl_exec($handle);
Expand All @@ -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:
*
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand All @@ -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();
Expand All @@ -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.
*
Expand Down Expand Up @@ -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);
Expand All @@ -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.
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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
*
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions generator/config/CustomPhpStanFunctionMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
];

0 comments on commit e19610c

Please sign in to comment.