Skip to content

Commit 26171c3

Browse files
committed
Also allow casting CurlMultiHandles
1 parent ea2b0d3 commit 26171c3

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

ext/curl/interface.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ static void curl_free_obj(zend_object *object);
241241
static HashTable *curl_get_gc(zend_object *object, zval **table, int *n);
242242
static zend_function *curl_get_constructor(zend_object *object);
243243
static zend_object *curl_clone_obj(zend_object *object);
244-
static int curl_cast_object(zend_object *obj, zval *result, int type);
245244
php_curl *init_curl_handle_into_zval(zval *curl);
246245
static inline int build_mime_structure_from_hash(php_curl *ch, zval *zpostfields);
247246

@@ -1305,7 +1304,7 @@ static HashTable *curl_get_gc(zend_object *object, zval **table, int *n)
13051304
return zend_std_get_properties(object);
13061305
}
13071306

1308-
static int curl_cast_object(zend_object *obj, zval *result, int type)
1307+
int curl_cast_object(zend_object *obj, zval *result, int type)
13091308
{
13101309
if (type == IS_LONG) {
13111310
/* For better backward compatibility, make (int) $curl_handle return the object ID,

ext/curl/multi.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,7 @@ void curl_multi_register_class(const zend_function_entry *method_entries) {
608608
curl_multi_handlers.get_gc = curl_multi_get_gc;
609609
curl_multi_handlers.get_constructor = curl_multi_get_constructor;
610610
curl_multi_handlers.clone_obj = NULL;
611+
curl_multi_handlers.cast_object = curl_cast_object;
611612
}
612613

613614
#endif

ext/curl/php_curl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ PHP_CURL_API extern zend_class_entry *curl_share_ce;
176176
void curl_multi_register_class(const zend_function_entry *method_entries);
177177
void curl_share_register_class(const zend_function_entry *method_entries);
178178
void curlfile_register_class(void);
179+
int curl_cast_object(zend_object *obj, zval *result, int type);
179180

180181
PHP_CURL_API extern zend_class_entry *curl_CURLFile_class;
181182

ext/curl/tests/curl_int_cast.phpt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,13 @@ unset($handle2);
1313
$handle3 = curl_init();
1414
var_dump((int) $handle3);
1515

16+
// Also works for CurlMultiHandle.
17+
$handle4 = curl_multi_init();
18+
var_dump((int) $handle4);
19+
1620
?>
1721
--EXPECT--
1822
int(1)
1923
int(2)
2024
int(2)
25+
int(3)

0 commit comments

Comments
 (0)