@@ -223,7 +223,6 @@ static zend_object_handlers curl_object_handlers;
223
223
static zend_object * curl_create_object (zend_class_entry * class_type );
224
224
static void curl_free_obj (zend_object * object );
225
225
static HashTable * curl_get_gc (zend_object * object , zval * * table , int * n );
226
- static zend_function * curl_get_constructor (zend_object * object );
227
226
static zend_object * curl_clone_obj (zend_object * object );
228
227
php_curl * init_curl_handle_into_zval (zval * curl );
229
228
static inline zend_result build_mime_structure_from_hash (php_curl * ch , zval * zpostfields );
@@ -1334,7 +1333,6 @@ PHP_MINIT_FUNCTION(curl)
1334
1333
curl_object_handlers .offset = XtOffsetOf (php_curl , std );
1335
1334
curl_object_handlers .free_obj = curl_free_obj ;
1336
1335
curl_object_handlers .get_gc = curl_get_gc ;
1337
- curl_object_handlers .get_constructor = curl_get_constructor ;
1338
1336
curl_object_handlers .clone_obj = curl_clone_obj ;
1339
1337
curl_object_handlers .cast_object = curl_cast_object ;
1340
1338
curl_object_handlers .compare = zend_objects_not_comparable ;
@@ -1362,11 +1360,6 @@ static zend_object *curl_create_object(zend_class_entry *class_type) {
1362
1360
return & intern -> std ;
1363
1361
}
1364
1362
1365
- static zend_function * curl_get_constructor (zend_object * object ) {
1366
- zend_throw_error (NULL , "Cannot directly construct CurlHandle, use curl_init() instead" );
1367
- return NULL ;
1368
- }
1369
-
1370
1363
static zend_object * curl_clone_obj (zend_object * object ) {
1371
1364
php_curl * ch ;
1372
1365
CURL * cp ;
@@ -2036,8 +2029,7 @@ static void _php_curl_set_default_options(php_curl *ch)
2036
2029
}
2037
2030
/* }}} */
2038
2031
2039
- /* {{{ Initialize a cURL session */
2040
- PHP_FUNCTION (curl_init )
2032
+ static void _php_curl_init (INTERNAL_FUNCTION_PARAMETERS )
2041
2033
{
2042
2034
php_curl * ch ;
2043
2035
CURL * cp ;
@@ -2048,14 +2040,16 @@ PHP_FUNCTION(curl_init)
2048
2040
Z_PARAM_STR_OR_NULL (url )
2049
2041
ZEND_PARSE_PARAMETERS_END ();
2050
2042
2043
+ ch = Z_CURL_P (return_value );
2044
+ init_curl_handle (ch );
2045
+
2051
2046
cp = curl_easy_init ();
2052
2047
if (!cp ) {
2053
2048
php_error_docref (NULL , E_WARNING , "Could not initialize a new cURL handle" );
2049
+ zval_ptr_dtor (return_value );
2054
2050
RETURN_FALSE ;
2055
2051
}
2056
2052
2057
- ch = init_curl_handle_into_zval (return_value );
2058
-
2059
2053
ch -> cp = cp ;
2060
2054
2061
2055
ch -> handlers .write -> method = PHP_CURL_STDOUT ;
@@ -2071,6 +2065,19 @@ PHP_FUNCTION(curl_init)
2071
2065
}
2072
2066
}
2073
2067
}
2068
+
2069
+ /* {{{ Initialize a cURL session */
2070
+ PHP_METHOD (CurlHandle , __construct )
2071
+ {
2072
+ return_value = ZEND_THIS ;
2073
+ _php_curl_init (INTERNAL_FUNCTION_PARAM_PASSTHRU );
2074
+ }
2075
+
2076
+ PHP_FUNCTION (curl_init )
2077
+ {
2078
+ object_init_ex (return_value , curl_ce );
2079
+ _php_curl_init (INTERNAL_FUNCTION_PARAM_PASSTHRU );
2080
+ }
2074
2081
/* }}} */
2075
2082
2076
2083
void _php_setup_easy_copy_handlers (php_curl * ch , php_curl * source )
@@ -3291,11 +3298,9 @@ PHP_FUNCTION(curl_setopt)
3291
3298
zend_long options ;
3292
3299
php_curl * ch ;
3293
3300
3294
- ZEND_PARSE_PARAMETERS_START (3 , 3 )
3295
- Z_PARAM_OBJECT_OF_CLASS (zid , curl_ce )
3296
- Z_PARAM_LONG (options )
3297
- Z_PARAM_ZVAL (zvalue )
3298
- ZEND_PARSE_PARAMETERS_END ();
3301
+ if (zend_parse_method_parameters (ZEND_NUM_ARGS (), getThis (), "Olz" , & zid , curl_ce , & options , & zvalue ) == FAILURE ) {
3302
+ RETURN_THROWS ();
3303
+ }
3299
3304
3300
3305
ch = Z_CURL_P (zid );
3301
3306
@@ -3315,10 +3320,9 @@ PHP_FUNCTION(curl_setopt_array)
3315
3320
zend_ulong option ;
3316
3321
zend_string * string_key ;
3317
3322
3318
- ZEND_PARSE_PARAMETERS_START (2 , 2 )
3319
- Z_PARAM_OBJECT_OF_CLASS (zid , curl_ce )
3320
- Z_PARAM_ARRAY (arr )
3321
- ZEND_PARSE_PARAMETERS_END ();
3323
+ if (zend_parse_method_parameters (ZEND_NUM_ARGS (), getThis (), "Oa" , & zid , curl_ce , & arr ) == FAILURE ) {
3324
+ RETURN_THROWS ();
3325
+ }
3322
3326
3323
3327
ch = Z_CURL_P (zid );
3324
3328
@@ -3360,9 +3364,9 @@ PHP_FUNCTION(curl_exec)
3360
3364
zval * zid ;
3361
3365
php_curl * ch ;
3362
3366
3363
- ZEND_PARSE_PARAMETERS_START ( 1 , 1 )
3364
- Z_PARAM_OBJECT_OF_CLASS ( zid , curl_ce )
3365
- ZEND_PARSE_PARAMETERS_END ();
3367
+ if ( zend_parse_method_parameters ( ZEND_NUM_ARGS (), getThis (), "O" , & zid , curl_ce ) == FAILURE ) {
3368
+ RETURN_THROWS ();
3369
+ }
3366
3370
3367
3371
ch = Z_CURL_P (zid );
3368
3372
@@ -3415,11 +3419,9 @@ PHP_FUNCTION(curl_getinfo)
3415
3419
zend_long option ;
3416
3420
bool option_is_null = 1 ;
3417
3421
3418
- ZEND_PARSE_PARAMETERS_START (1 , 2 )
3419
- Z_PARAM_OBJECT_OF_CLASS (zid , curl_ce )
3420
- Z_PARAM_OPTIONAL
3421
- Z_PARAM_LONG_OR_NULL (option , option_is_null )
3422
- ZEND_PARSE_PARAMETERS_END ();
3422
+ if (zend_parse_method_parameters (ZEND_NUM_ARGS (), getThis (), "O|l!" , & zid , curl_ce , & option , & option_is_null ) == FAILURE ) {
3423
+ RETURN_THROWS ();
3424
+ }
3423
3425
3424
3426
ch = Z_CURL_P (zid );
3425
3427
@@ -3699,9 +3701,9 @@ PHP_FUNCTION(curl_errno)
3699
3701
zval * zid ;
3700
3702
php_curl * ch ;
3701
3703
3702
- ZEND_PARSE_PARAMETERS_START ( 1 , 1 )
3703
- Z_PARAM_OBJECT_OF_CLASS ( zid , curl_ce )
3704
- ZEND_PARSE_PARAMETERS_END ();
3704
+ if ( zend_parse_method_parameters ( ZEND_NUM_ARGS (), getThis (), "O" , & zid , curl_ce ) == FAILURE ) {
3705
+ RETURN_THROWS ();
3706
+ }
3705
3707
3706
3708
ch = Z_CURL_P (zid );
3707
3709
@@ -3898,9 +3900,9 @@ PHP_FUNCTION(curl_reset)
3898
3900
zval * zid ;
3899
3901
php_curl * ch ;
3900
3902
3901
- ZEND_PARSE_PARAMETERS_START ( 1 , 1 )
3902
- Z_PARAM_OBJECT_OF_CLASS ( zid , curl_ce )
3903
- ZEND_PARSE_PARAMETERS_END ();
3903
+ if ( zend_parse_method_parameters ( ZEND_NUM_ARGS (), getThis (), "O" , & zid , curl_ce ) == FAILURE ) {
3904
+ RETURN_THROWS ();
3905
+ }
3904
3906
3905
3907
ch = Z_CURL_P (zid );
3906
3908
@@ -3923,10 +3925,9 @@ PHP_FUNCTION(curl_escape)
3923
3925
zval * zid ;
3924
3926
php_curl * ch ;
3925
3927
3926
- ZEND_PARSE_PARAMETERS_START (2 ,2 )
3927
- Z_PARAM_OBJECT_OF_CLASS (zid , curl_ce )
3928
- Z_PARAM_STR (str )
3929
- ZEND_PARSE_PARAMETERS_END ();
3928
+ if (zend_parse_method_parameters (ZEND_NUM_ARGS (), getThis (), "OS" , & zid , curl_ce , & str ) == FAILURE ) {
3929
+ RETURN_THROWS ();
3930
+ }
3930
3931
3931
3932
ch = Z_CURL_P (zid );
3932
3933
@@ -3952,10 +3953,9 @@ PHP_FUNCTION(curl_unescape)
3952
3953
zend_string * str ;
3953
3954
php_curl * ch ;
3954
3955
3955
- ZEND_PARSE_PARAMETERS_START (2 ,2 )
3956
- Z_PARAM_OBJECT_OF_CLASS (zid , curl_ce )
3957
- Z_PARAM_STR (str )
3958
- ZEND_PARSE_PARAMETERS_END ();
3956
+ if (zend_parse_method_parameters (ZEND_NUM_ARGS (), getThis (), "OS" , & zid , curl_ce , & str ) == FAILURE ) {
3957
+ RETURN_THROWS ();
3958
+ }
3959
3959
3960
3960
ch = Z_CURL_P (zid );
3961
3961
@@ -3979,10 +3979,9 @@ PHP_FUNCTION(curl_pause)
3979
3979
zval * zid ;
3980
3980
php_curl * ch ;
3981
3981
3982
- ZEND_PARSE_PARAMETERS_START (2 ,2 )
3983
- Z_PARAM_OBJECT_OF_CLASS (zid , curl_ce )
3984
- Z_PARAM_LONG (bitmask )
3985
- ZEND_PARSE_PARAMETERS_END ();
3982
+ if (zend_parse_method_parameters (ZEND_NUM_ARGS (), getThis (), "Ol" , & zid , curl_ce , & bitmask ) == FAILURE ) {
3983
+ RETURN_THROWS ();
3984
+ }
3986
3985
3987
3986
ch = Z_CURL_P (zid );
3988
3987
@@ -3998,9 +3997,9 @@ PHP_FUNCTION(curl_upkeep)
3998
3997
zval * zid ;
3999
3998
php_curl * ch ;
4000
3999
4001
- ZEND_PARSE_PARAMETERS_START ( 1 , 1 )
4002
- Z_PARAM_OBJECT_OF_CLASS ( zid , curl_ce )
4003
- ZEND_PARSE_PARAMETERS_END ();
4000
+ if ( zend_parse_method_parameters ( ZEND_NUM_ARGS (), getThis (), "O" , & zid , curl_ce ) == FAILURE ) {
4001
+ RETURN_THROWS ();
4002
+ }
4004
4003
4005
4004
ch = Z_CURL_P (zid );
4006
4005
0 commit comments