PHP 8 compatibility
authorMichael Wallner <mike@php.net>
Mon, 21 Sep 2020 12:23:15 +0000 (14:23 +0200)
committerMichael Wallner <mike@php.net>
Mon, 21 Sep 2020 12:23:15 +0000 (14:23 +0200)
42 files changed:
.travis.yml
config9.m4
scripts/gen_travis_yml.php
src/php_http_client.c
src/php_http_client_curl.c
src/php_http_client_request.c
src/php_http_client_response.c
src/php_http_cookie.c
src/php_http_cookie.h
src/php_http_encoding.c
src/php_http_encoding.h
src/php_http_env.c
src/php_http_env_request.c
src/php_http_env_response.c
src/php_http_etag.c
src/php_http_etag.h
src/php_http_header.c
src/php_http_header_parser.c
src/php_http_message.c
src/php_http_message.h
src/php_http_message_body.c
src/php_http_message_body.h
src/php_http_message_parser.c
src/php_http_misc.c
src/php_http_misc.h
src/php_http_negotiate.c
src/php_http_options.c
src/php_http_params.c
src/php_http_querystring.c
src/php_http_url.c
tests/client024.phpt
tests/gh-issue11.phpt
tests/gh-issue42.phpt
tests/message006.phpt [deleted file]
tests/phpinfo.phpt
tests/propertyproxy001.phpt [deleted file]
tests/querystring001.phpt [deleted file]
tests/skipif.inc
tests/urlparser004.phpt
tests/urlparser006.phpt
tests/urlparser010.phpt
tests/urlparser012.phpt

index 10fef4c407534969b18baeb75a43c10e08d2f623..8d71284338c3d32e535fcb8b3f13e811663ab792 100644 (file)
@@ -23,24 +23,20 @@ before_cache:
  - find $HOME/cache -name '*.gcda' -o -name '*.gcno' -delete
 
 env:
- - PHP=7.0 enable_debug=yes enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes
- - PHP=7.1 enable_debug=yes enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes
- - PHP=7.2 enable_debug=yes enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes
- - PHP=7.3 enable_debug=yes enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes
- - PHP=master enable_debug=yes enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes
- - PHP=7.4 with_http_libicu_dir=no with_http_libidn_dir=no with_http_libidn2_dir=no with_http_libcurl_dir=no with_http_libevent_dir=no with_http_libbrotli_dir=no
- - PHP=7.4 PECLs=event enable_sockets=yes enable_debug=no enable_maintainer_zts=no enable_json=yes enable_hash=yes enable_iconv=yes
- - PHP=7.4 PECLs=event enable_sockets=yes enable_debug=yes enable_maintainer_zts=no enable_json=yes enable_hash=yes enable_iconv=yes
- - PHP=7.4 PECLs=event enable_sockets=yes enable_debug=no enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes
- - PHP=7.4 PECLs=event enable_sockets=yes enable_debug=yes enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes
- - CFLAGS='-O0 -g --coverage' CXXFLAGS='-O0 -g --coverage' PHP=7.4 PECLs=event enable_sockets=yes enable_json=yes enable_hash=yes enable_iconv=yes with_http_libicu_dir=yes with_http_libidn_dir=no with_http_libidn2_dir=no 
- - CFLAGS='-O0 -g --coverage' CXXFLAGS='-O0 -g --coverage' PHP=7.4 PECLs=event enable_sockets=yes enable_json=yes enable_hash=yes enable_iconv=yes with_http_libidn_dir=yes with_http_libicu_dir=no with_http_libidn2_dir=no 
- - CFLAGS='-O0 -g --coverage' CXXFLAGS='-O0 -g --coverage' PHP=7.4 PECLs=event enable_sockets=yes enable_json=yes enable_hash=yes enable_iconv=yes with_http_libidn2_dir=yes with_http_libicu_dir=no with_http_libidn_dir=no 
+ - PHP=master enable_debug=yes enable_zts=yes enable_iconv=yes
+ - PHP=8.0 with_http_libicu_dir=no with_http_libidn_dir=no with_http_libidn2_dir=no with_http_libcurl_dir=no with_http_libevent_dir=no with_http_libbrotli_dir=no
+ - PHP=8.0 enable_debug=no enable_zts=no enable_iconv=yes
+ - PHP=8.0 enable_debug=yes enable_zts=no enable_iconv=yes
+ - PHP=8.0 enable_debug=no enable_zts=yes enable_iconv=yes
+ - PHP=8.0 enable_debug=yes enable_zts=yes enable_iconv=yes
+ - CFLAGS='-O0 -g --coverage' CXXFLAGS='-O0 -g --coverage' PHP=8.0 enable_iconv=yes with_http_libicu_dir=yes with_http_libidn_dir=no with_http_libidn2_dir=no 
+ - CFLAGS='-O0 -g --coverage' CXXFLAGS='-O0 -g --coverage' PHP=8.0 enable_iconv=yes with_http_libidn_dir=yes with_http_libicu_dir=no with_http_libidn2_dir=no 
+ - CFLAGS='-O0 -g --coverage' CXXFLAGS='-O0 -g --coverage' PHP=8.0 enable_iconv=yes with_http_libidn2_dir=yes with_http_libicu_dir=no with_http_libidn_dir=no 
 
 matrix:
  fast_finish: true
  allow_failures:
-  - env: PHP=master enable_debug=yes enable_maintainer_zts=yes enable_json=yes enable_hash=yes enable_iconv=yes
+  - env: PHP=master enable_debug=yes enable_zts=yes enable_iconv=yes
 
 install:
  - |
index 66a4ec53cc453279cfa95311c555100ed50b1f57..998d48e0f02e9f2a78a7255a7d702c5479b7e0e8 100644 (file)
@@ -161,7 +161,6 @@ if test "$PHP_HTTP" != "no"; then
        ], [
                AC_MSG_ERROR([please install and enable pecl/raphf])
        ])
-       PECL_HAVE_PHP_EXT([hash])
        PECL_HAVE_PHP_EXT([iconv])
 
        dnl DONE
index c0adebece5789da27ae2b1e6917f6568abd6a985..9e9b12732edd1b4e9927f0573ff6837dc1946291 100755 (executable)
@@ -27,14 +27,12 @@ env:
 <?php
 
 $gen = include "./travis/pecl/gen-matrix.php";
-$cur = "7.4";
+$cur = "8.0";
 $env = $gen([
 // most useful for all additional versions except current
-       "PHP" => ["7.0", "7.1", "7.2", "7.3", "master"],
+       "PHP" => ["master"],
        "enable_debug" => "yes",
-       "enable_maintainer_zts" => "yes",
-       "enable_json" => "yes",
-       "enable_hash" => "yes",
+       "enable_zts" => "yes",
        "enable_iconv" => "yes",
 ], [
 // everything disabled for current
@@ -48,22 +46,18 @@ $env = $gen([
 ], [
 // everything enabled for current, switching debug/zts
        "PHP" => $cur,
-       "PECLs" => "event",                     // for tests/client029.phpt
-       "enable_sockets" => "yes",      // needed by pecl/event
+//     "PECLs" => "event",                     // for tests/client029.phpt
+//     "enable_sockets" => "yes",      // needed by pecl/event
        "enable_debug",
-       "enable_maintainer_zts",
-       "enable_json" => "yes",
-       "enable_hash" => "yes",
+       "enable_zts",
        "enable_iconv" => "yes",
 ], [
 // once everything enabled for current, with coverage
        "CFLAGS" => "'-O0 -g --coverage'",
        "CXXFLAGS" => "'-O0 -g --coverage'",
        "PHP" => $cur,
-       "PECLs" => "event",                     // for tests/client029.phpt
-       "enable_sockets" => "yes",      // needed by pecl/event
-       "enable_json" => "yes",
-       "enable_hash" => "yes",
+//     "PECLs" => "event",                     // for tests/client029.phpt
+//     "enable_sockets" => "yes",      // needed by pecl/event
        "enable_iconv" => "yes",
        [
                "with_http_libicu_dir",
index 9551dd0bbe775f252a8893f090a17f06ddb5d36f..69257f15defed898146941b06432d619ff79b55e 100644 (file)
@@ -74,7 +74,7 @@ void php_http_client_options_set_subr(zval *instance, char *key, size_t len, zva
                zval old_opts_tmp, *old_opts, new_opts, *entry = NULL;
 
                array_init(&new_opts);
-               old_opts = zend_read_property(this_ce, instance, ZEND_STRL("options"), 0, &old_opts_tmp);
+               old_opts = zend_read_property(this_ce, Z_OBJ_P(instance), ZEND_STRL("options"), 0, &old_opts_tmp);
 
                if (Z_TYPE_P(old_opts) == IS_ARRAY) {
                        array_copy(Z_ARRVAL_P(old_opts), Z_ARRVAL(new_opts));
@@ -97,7 +97,7 @@ void php_http_client_options_set_subr(zval *instance, char *key, size_t len, zva
                        }
                }
 
-               zend_update_property(this_ce, instance, ZEND_STRL("options"), &new_opts);
+               zend_update_property(this_ce, Z_OBJ_P(instance), ZEND_STRL("options"), &new_opts);
                zval_ptr_dtor(&new_opts);
        }
 }
@@ -112,7 +112,7 @@ void php_http_client_options_set(zval *instance, zval *opts)
        array_init(&new_opts);
 
        if (!opts || !zend_hash_num_elements(Z_ARRVAL_P(opts))) {
-               zend_update_property(this_ce, instance, ZEND_STRL("options"), &new_opts);
+               zend_update_property(this_ce, Z_OBJ_P(instance), ZEND_STRL("options"), &new_opts);
                zval_ptr_dtor(&new_opts);
        } else {
                zval old_opts_tmp, *old_opts, add_opts, *opt;
@@ -125,9 +125,9 @@ void php_http_client_options_set(zval *instance, zval *opts)
                                if (Z_TYPE_P(opt) == IS_ARRAY && (zend_string_equals_literal(key.key, "ssl") || zend_string_equals_literal(key.key, "cookies"))) {
                                        php_http_client_options_set_subr(instance, key.key->val, key.key->len, opt, 0);
                                } else if (is_client && (zend_string_equals_literal(key.key, "recordHistory") || zend_string_equals_literal(key.key, "responseMessageClass"))) {
-                                       zend_update_property(this_ce, instance, key.key->val, key.key->len, opt);
+                                       zend_update_property(this_ce, Z_OBJ_P(instance), key.key->val, key.key->len, opt);
                                } else if (Z_TYPE_P(opt) == IS_NULL) {
-                                       old_opts = zend_read_property(this_ce, instance, ZEND_STRL("options"), 0, &old_opts_tmp);
+                                       old_opts = zend_read_property(this_ce, Z_OBJ_P(instance), ZEND_STRL("options"), 0, &old_opts_tmp);
                                        if (Z_TYPE_P(old_opts) == IS_ARRAY) {
                                                zend_symtable_del(Z_ARRVAL_P(old_opts), key.key);
                                        }
@@ -139,12 +139,12 @@ void php_http_client_options_set(zval *instance, zval *opts)
                }
                ZEND_HASH_FOREACH_END();
 
-               old_opts = zend_read_property(this_ce, instance, ZEND_STRL("options"), 0, &old_opts_tmp);
+               old_opts = zend_read_property(this_ce, Z_OBJ_P(instance), ZEND_STRL("options"), 0, &old_opts_tmp);
                if (Z_TYPE_P(old_opts) == IS_ARRAY) {
                        array_copy(Z_ARRVAL_P(old_opts), Z_ARRVAL(new_opts));
                }
                array_join(Z_ARRVAL(add_opts), Z_ARRVAL(new_opts), 0, 0);
-               zend_update_property(this_ce, instance, ZEND_STRL("options"), &new_opts);
+               zend_update_property(this_ce, Z_OBJ_P(instance), ZEND_STRL("options"), &new_opts);
                zval_ptr_dtor(&new_opts);
                zval_ptr_dtor(&add_opts);
        }
@@ -153,7 +153,7 @@ void php_http_client_options_set(zval *instance, zval *opts)
 void php_http_client_options_get_subr(zval *instance, char *key, size_t len, zval *return_value)
 {
        zend_class_entry *this_ce = Z_OBJCE_P(instance);
-       zval *options, opts_tmp, *opts = zend_read_property(this_ce, instance, ZEND_STRL("options"), 0, &opts_tmp);
+       zval *options, opts_tmp, *opts = zend_read_property(this_ce, Z_OBJ_P(instance), ZEND_STRL("options"), 0, &opts_tmp);
 
        if ((Z_TYPE_P(opts) == IS_ARRAY) && (options = zend_symtable_str_find(Z_ARRVAL_P(opts), key, len))) {
                RETVAL_ZVAL(options, 1, 0);
@@ -367,11 +367,11 @@ zend_object *php_http_client_object_new(zend_class_entry *ce)
        return &php_http_client_object_new_ex(ce, NULL)->zo;
 }
 
-static HashTable *php_http_client_object_get_gc(zval *object, zval **table, int *n)
+static HashTable *php_http_client_object_get_gc(zend_object *object, zval **table, int *n)
 {
-       php_http_client_object_t *obj = PHP_HTTP_OBJ(NULL, object);
+       php_http_client_object_t *obj = PHP_HTTP_OBJ(object, NULL);
        zend_llist_element *el = NULL;
-       HashTable *props = Z_OBJPROP_P(object);
+       HashTable *props = object->handlers->get_properties(object);
        uint32_t count = zend_hash_num_elements(props) + zend_llist_count(&obj->client->responses) + zend_llist_count(&obj->client->requests) + 2;
        zval *val;
 
@@ -417,7 +417,7 @@ static HashTable *php_http_client_object_get_gc(zval *object, zval **table, int
 
 static void handle_history(zval *zclient, php_http_message_t *request, php_http_message_t *response)
 {
-       zval new_hist, old_hist_tmp, *old_hist = zend_read_property(php_http_client_class_entry, zclient, ZEND_STRL("history"), 0, &old_hist_tmp);
+       zval new_hist, old_hist_tmp, *old_hist = zend_read_property(php_http_client_class_entry, Z_OBJ_P(zclient), ZEND_STRL("history"), 0, &old_hist_tmp);
        php_http_message_t *req_copy = php_http_message_copy(request, NULL);
        php_http_message_t *res_copy = php_http_message_copy(response, NULL);
        php_http_message_t *zipped = php_http_message_zip(res_copy, req_copy);
@@ -429,7 +429,7 @@ static void handle_history(zval *zclient, php_http_message_t *request, php_http_
                php_http_message_object_prepend(&new_hist, old_hist, 1);
        }
 
-       zend_update_property(php_http_client_class_entry, zclient, ZEND_STRL("history"), &new_hist);
+       zend_update_property(php_http_client_class_entry, Z_OBJ_P(zclient), ZEND_STRL("history"), &new_hist);
        zval_ptr_dtor(&new_hist);
 }
 
@@ -450,7 +450,7 @@ static ZEND_RESULT_CODE handle_response(void *arg, php_http_client_t *client, ph
                /* ensure the message is of type response (could be uninitialized in case of early error, like DNS) */
                php_http_message_set_type(msg, PHP_HTTP_RESPONSE);
 
-               if (zend_is_true(zend_read_property(php_http_client_class_entry, &zclient, ZEND_STRL("recordHistory"), 0, &rec_hist_tmp))) {
+               if (zend_is_true(zend_read_property(php_http_client_class_entry, Z_OBJ(zclient), ZEND_STRL("recordHistory"), 0, &rec_hist_tmp))) {
                        handle_history(&zclient, e->request, *response);
                }
 
@@ -467,7 +467,7 @@ static ZEND_RESULT_CODE handle_response(void *arg, php_http_client_t *client, ph
                object_init(&info);
                info_ht = HASH_OF(&info);
                php_http_client_getopt(client, PHP_HTTP_CLIENT_OPT_TRANSFER_INFO, e->request, &info_ht);
-               zend_update_property(php_http_get_client_response_class_entry(), &zresponse, ZEND_STRL("transferInfo"), &info);
+               zend_update_property(php_http_get_client_response_class_entry(), Z_OBJ(zresponse), ZEND_STRL("transferInfo"), &info);
                zval_ptr_dtor(&info);
 
                zend_llist_add_element(&client->responses, &msg_obj);
@@ -548,12 +548,11 @@ static void handle_debug(void *arg, php_http_client_t *client, php_http_client_e
        ZVAL_STRINGL(&zdata, data, size);
 
        zend_replace_error_handling(EH_NORMAL, NULL, &zeh);
-       if (SUCCESS == zend_fcall_info_argn(&client_obj->debug.fci, 4, &zclient, &zreq, &ztype, &zdata)) {
-               ++client->callback.depth;
-               zend_fcall_info_call(&client_obj->debug.fci, &client_obj->debug.fcc, NULL, NULL);
-               --client->callback.depth;
-               zend_fcall_info_args_clear(&client_obj->debug.fci, 0);
-       }
+       zend_fcall_info_argn(&client_obj->debug.fci, 4, &zclient, &zreq, &ztype, &zdata);
+       ++client->callback.depth;
+       zend_fcall_info_call(&client_obj->debug.fci, &client_obj->debug.fcc, NULL, NULL);
+       --client->callback.depth;
+       zend_fcall_info_args_clear(&client_obj->debug.fci, 0);
        zend_restore_error_handling(&zeh);
 
        zval_ptr_dtor(&zclient);
@@ -593,7 +592,7 @@ static PHP_METHOD(HttpClient, __construct)
                }
 
                object_init_ex(&os, spl_ce_SplObjectStorage);
-               zend_update_property(php_http_client_class_entry, getThis(), ZEND_STRL("observers"), &os);
+               zend_update_property(php_http_client_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("observers"), &os);
                zval_ptr_dtor(&os);
 
                if (persistent_handle_name) {
@@ -637,13 +636,13 @@ static HashTable *combined_options(zval *client, zval *request)
 {
        HashTable *options;
        unsigned num_options = 0;
-       zval z_roptions, z_options_tmp, *z_coptions = zend_read_property(php_http_client_class_entry, client, ZEND_STRL("options"), 0, &z_options_tmp);
+       zval z_roptions, z_options_tmp, *z_coptions = zend_read_property(php_http_client_class_entry, Z_OBJ_P(client), ZEND_STRL("options"), 0, &z_options_tmp);
 
        if (Z_TYPE_P(z_coptions) == IS_ARRAY) {
                num_options = zend_hash_num_elements(Z_ARRVAL_P(z_coptions));
        }
        ZVAL_UNDEF(&z_roptions);
-       zend_call_method_with_0_params(request, NULL, NULL, "getOptions", &z_roptions);
+       zend_call_method_with_0_params(Z_OBJ_P(request), NULL, NULL, "getOptions", &z_roptions);
        if (Z_TYPE(z_roptions) == IS_ARRAY) {
                unsigned num = zend_hash_num_elements(Z_ARRVAL(z_roptions));
                if (num > num_options) {
@@ -868,7 +867,7 @@ static PHP_METHOD(HttpClient, getHistory)
 
        php_http_expect(SUCCESS == zend_parse_parameters_none(), invalid_arg, return);
 
-       zhistory = zend_read_property(php_http_client_class_entry, getThis(), ZEND_STRL("history"), 0, &zhistory_tmp);
+       zhistory = zend_read_property(php_http_client_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("history"), 0, &zhistory_tmp);
        RETVAL_ZVAL(zhistory, 1, 0);
 }
 
@@ -998,7 +997,7 @@ static PHP_METHOD(HttpClient, notify)
        php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|O!o!", &request, php_http_get_client_request_class_entry(), &zprogress), invalid_arg, return);
 
        client_obj = PHP_HTTP_OBJ(NULL, getThis());
-       observers = zend_read_property(php_http_client_class_entry, getThis(), ZEND_STRL("observers"), 0, &observers_tmp);
+       observers = zend_read_property(php_http_client_class_entry, &client_obj->zo, ZEND_STRL("observers"), 0, &observers_tmp);
 
        if (Z_TYPE_P(observers) != IS_OBJECT) {
                php_http_throw(unexpected_val, "Observer storage is corrupted");
@@ -1044,7 +1043,7 @@ static PHP_METHOD(HttpClient, attach)
        php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &observer, spl_ce_SplObserver), invalid_arg, return);
 
        client_obj = PHP_HTTP_OBJ(NULL, getThis());
-       observers = zend_read_property(php_http_client_class_entry, getThis(), ZEND_STRL("observers"), 0, &observers_tmp);
+       observers = zend_read_property(php_http_client_class_entry, &client_obj->zo, ZEND_STRL("observers"), 0, &observers_tmp);
 
        if (Z_TYPE_P(observers) != IS_OBJECT) {
                php_http_throw(unexpected_val, "Observer storage is corrupted");
@@ -1056,7 +1055,7 @@ static PHP_METHOD(HttpClient, attach)
        }
 
        ZVAL_UNDEF(&retval);
-       zend_call_method_with_1_params(observers, NULL, NULL, "attach", &retval, observer);
+       zend_call_method_with_1_params(Z_OBJ_P(observers), NULL, NULL, "attach", &retval, observer);
        zval_ptr_dtor(&retval);
 
        RETVAL_ZVAL(getThis(), 1, 0);
@@ -1071,7 +1070,7 @@ static PHP_METHOD(HttpClient, detach)
 
        php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &observer, spl_ce_SplObserver), invalid_arg, return);
 
-       observers = zend_read_property(php_http_client_class_entry, getThis(), ZEND_STRL("observers"), 0, &observers_tmp);
+       observers = zend_read_property(php_http_client_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("observers"), 0, &observers_tmp);
 
        if (Z_TYPE_P(observers) != IS_OBJECT) {
                php_http_throw(unexpected_val, "Observer storage is corrupted");
@@ -1079,7 +1078,7 @@ static PHP_METHOD(HttpClient, detach)
        }
 
        ZVAL_UNDEF(&retval);
-       zend_call_method_with_1_params(observers, NULL, NULL, "detach", &retval, observer);
+       zend_call_method_with_1_params(Z_OBJ_P(observers), NULL, NULL, "detach", &retval, observer);
        zval_ptr_dtor(&retval);
 
        RETVAL_ZVAL(getThis(), 1, 0);
@@ -1093,7 +1092,7 @@ static PHP_METHOD(HttpClient, getObservers)
 
        php_http_expect(SUCCESS == zend_parse_parameters_none(), invalid_arg, return);
 
-       observers = zend_read_property(php_http_client_class_entry, getThis(), ZEND_STRL("observers"), 0, &observers_tmp);
+       observers = zend_read_property(php_http_client_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("observers"), 0, &observers_tmp);
 
        if (Z_TYPE_P(observers) != IS_OBJECT) {
                php_http_throw(unexpected_val, "Observer storage is corrupted");
@@ -1169,7 +1168,7 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpClient, getOptions)
 {
        if (SUCCESS == zend_parse_parameters_none()) {
-               zval options_tmp, *options = zend_read_property(php_http_client_class_entry, getThis(), ZEND_STRL("options"), 0, &options_tmp);
+               zval options_tmp, *options = zend_read_property(php_http_client_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("options"), 0, &options_tmp);
                RETVAL_ZVAL(options, 1, 0);
        }
 }
index 94cdf474180549023805549a22230d02e20b3b4b..9a6ce26d506872a321bf95b3e09d681d62d14898 100644 (file)
@@ -331,7 +331,9 @@ static ZEND_RESULT_CODE php_http_curle_get_info(CURL *ch, HashTable *info)
        long l = 0;
        double d = 0;
        struct curl_slist *s = NULL, *p = NULL;
-       zval tmp = {{0}};
+       zval tmp;
+
+       ZVAL_NULL(&tmp);
 
        /* BEGIN::CURLINFO */
        if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_EFFECTIVE_URL, &c)) {
index 9055f490f379097411ed6b73fb86b68e0a4c1646..52e9c7098126143aacc7fe56ad565b9ada557002 100644 (file)
@@ -230,7 +230,7 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpClientRequest, getOptions)
 {
        if (SUCCESS == zend_parse_parameters_none()) {
-               zval tmp, *zoptions = zend_read_property(php_http_client_request_class_entry, getThis(), ZEND_STRL("options"), 0, &tmp);
+               zval tmp, *zoptions = zend_read_property(php_http_client_request_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("options"), 0, &tmp);
                RETURN_ZVAL(zoptions, 1, 0);
        }
 }
index 34748aaa3e4a0b8ea4f53324c5eb2c2ce3885145..722b4e03ac1b58494593f0a35430098f76be3b72 100644 (file)
@@ -101,7 +101,7 @@ static PHP_METHOD(HttpClientResponse, getTransferInfo)
 
        php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|s", &info_name, &info_len), invalid_arg, return);
 
-       info = zend_read_property(php_http_client_response_class_entry, getThis(), ZEND_STRL("transferInfo"), 0, &info_tmp);
+       info = zend_read_property(php_http_client_response_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("transferInfo"), 0, &info_tmp);
 
        /* request completed? */
        if (Z_TYPE_P(info) != IS_OBJECT) {
@@ -110,7 +110,7 @@ static PHP_METHOD(HttpClientResponse, getTransferInfo)
        }
 
        if (info_len && info_name) {
-               info = zend_read_property(NULL, info, php_http_pretty_key(info_name, info_len, 0, 0), info_len, 0, &info_name_tmp);
+               info = zend_read_property(NULL, Z_OBJ_P(info), php_http_pretty_key(info_name, info_len, 0, 0), info_len, 0, &info_name_tmp);
 
                if (!info) {
                        php_http_throw(unexpected_val, "Could not find transfer info with name '%s'", info_name);
index 1186ca0535aa37394e90da8b9742e3a6d09d1bb7..ecdf94e256e314980339202e3685517c69050f17 100644 (file)
@@ -406,9 +406,9 @@ php_http_cookie_object_t *php_http_cookie_object_new_ex(zend_class_entry *ce, ph
                } \
        } while(0)
 
-zend_object *php_http_cookie_object_clone(zval *obj)
+zend_object *php_http_cookie_object_clone(zend_object *obj)
 {
-       php_http_cookie_object_t *new_obj, *old_obj = PHP_HTTP_OBJ(NULL, obj);
+       php_http_cookie_object_t *new_obj, *old_obj = PHP_HTTP_OBJ(obj, NULL);
 
        PHP_HTTP_COOKIE_OBJECT_INIT(old_obj);
 
index e7b924e3c9eb9c4bd296a3754475f5356ac0feda..3186d6ffa6de5b481b5b4834f838de64a9e49cdd 100644 (file)
@@ -62,7 +62,7 @@ typedef struct php_http_cookie_object {
 
 zend_object *php_http_cookie_object_new(zend_class_entry *ce);
 php_http_cookie_object_t *php_http_cookie_object_new_ex(zend_class_entry *ce, php_http_cookie_list_t *list);
-zend_object *php_http_cookie_object_clone(zval *this_ptr);
+zend_object *php_http_cookie_object_clone(zend_object *this_ptr);
 void php_http_cookie_object_free(zend_object *object);
 
 PHP_MINIT_FUNCTION(http_cookie);
index 3e57e2932e53233c99fa7fd408b724c4604a4f31..2e3007b7ff4940fba218946101e6751a110ee3f8 100644 (file)
@@ -477,9 +477,9 @@ php_http_encoding_stream_object_t *php_http_encoding_stream_object_new_ex(zend_c
        return o;
 }
 
-zend_object *php_http_encoding_stream_object_clone(zval *object)
+zend_object *php_http_encoding_stream_object_clone(zend_object *object)
 {
-       php_http_encoding_stream_object_t *new_obj, *old_obj = PHP_HTTP_OBJ(NULL, object);
+       php_http_encoding_stream_object_t *new_obj, *old_obj = PHP_HTTP_OBJ(object, NULL);
        php_http_encoding_stream_t *cpy = php_http_encoding_stream_copy(old_obj->stream, NULL);
 
        if (!cpy) {
index 3b59829d64338a10dc0c8d85b672e164540184ba..842bff792f8718924511cf25c7223da08be1c864 100644 (file)
@@ -76,7 +76,7 @@ PHP_HTTP_API zend_class_entry *php_http_get_encoding_stream_class_entry(void);
 
 zend_object *php_http_encoding_stream_object_new(zend_class_entry *ce);
 php_http_encoding_stream_object_t *php_http_encoding_stream_object_new_ex(zend_class_entry *ce, php_http_encoding_stream_t *s);
-zend_object *php_http_encoding_stream_object_clone(zval *object);
+zend_object *php_http_encoding_stream_object_clone(zend_object *object);
 void php_http_encoding_stream_object_free(zend_object *object);
 
 #endif
index 4afcd312b45d16b1ac011896f1646bed01af14d8..5e14ed21a436cf1dc2c8c1c7435c0d4237ca2bc9 100644 (file)
@@ -414,10 +414,12 @@ ZEND_RESULT_CODE php_http_env_set_response_status_line(long code, php_http_versi
 {
        sapi_header_line h = {NULL, 0, 0};
        ZEND_RESULT_CODE ret;
+       char *line;
 
-       h.line_len = spprintf(&h.line, 0, "HTTP/%u.%u %ld %s", v->major, v->minor, code, php_http_env_get_response_status_for_code(code));
+       h.line_len = spprintf(&line, 0, "HTTP/%u.%u %ld %s", v->major, v->minor, code, php_http_env_get_response_status_for_code(code));
+       h.line = line;
        ret = sapi_header_op(SAPI_HEADER_REPLACE, (void *) &h);
-       efree(h.line);
+       efree(line);
 
        return ret;
 }
@@ -429,10 +431,9 @@ ZEND_RESULT_CODE php_http_env_set_response_protocol_version(php_http_version_t *
 
 ZEND_RESULT_CODE php_http_env_set_response_header(long http_code, const char *header_str, size_t header_len, zend_bool replace)
 {
-       sapi_header_line h = {estrndup(header_str, header_len), header_len, http_code};
+       sapi_header_line h = {header_str, header_len, http_code};
        ZEND_RESULT_CODE ret = sapi_header_op(replace ? SAPI_HEADER_REPLACE : SAPI_HEADER_ADD, (void *) &h);
 
-       efree(h.line);
        return ret;
 }
 
@@ -440,14 +441,16 @@ ZEND_RESULT_CODE php_http_env_set_response_header_va(long http_code, zend_bool r
 {
        ZEND_RESULT_CODE ret = FAILURE;
        sapi_header_line h = {NULL, 0, http_code};
+       char *line;
 
-       h.line_len = vspprintf(&h.line, 0, fmt, argv);
+       h.line_len = vspprintf(&line, 0, fmt, argv);
+       h.line = line;
 
        if (h.line) {
                if (h.line_len) {
                        ret = sapi_header_op(replace ? SAPI_HEADER_REPLACE : SAPI_HEADER_ADD, (void *) &h);
                }
-               efree(h.line);
+               efree(line);
        }
        return ret;
 }
@@ -496,17 +499,19 @@ ZEND_RESULT_CODE php_http_env_set_response_header_value(long http_code, const ch
                } else {
                        sapi_header_line h;
                        ZEND_RESULT_CODE ret;
+                       char *line;
 
                        if (name_len > INT_MAX) {
                                return FAILURE;
                        }
                        h.response_code = http_code;
-                       h.line_len = spprintf(&h.line, 0, "%s: %s", name_str, data->val);
+                       h.line_len = spprintf(&line, 0, "%s: %s", name_str, data->val);
+                       h.line = line;
 
                        ret = sapi_header_op(replace ? SAPI_HEADER_REPLACE : SAPI_HEADER_ADD, (void *) &h);
 
                        zend_string_release(data);
-                       PTR_FREE(h.line);
+                       PTR_FREE(line);
 
                        return ret;
                }
index 7c6eea8d959d4442cd894e72eafddd7428c13391..0ed0eb84a7c05fa805a553cdca6b027e1ee419f8 100644 (file)
@@ -140,26 +140,26 @@ static PHP_METHOD(HttpEnvRequest, __construct)
        zsg = php_http_env_get_superglobal(ZEND_STRL("_GET"));
        object_init_ex(&zqs, php_http_querystring_get_class_entry());
        php_http_expect(SUCCESS == php_http_querystring_ctor(&zqs, zsg), unexpected_val, return);
-       zend_update_property(php_http_env_request_class_entry, getThis(), ZEND_STRL("query"), &zqs);
+       zend_update_property(php_http_env_request_class_entry, &obj->zo, ZEND_STRL("query"), &zqs);
        zval_ptr_dtor(&zqs);
 
        zsg = php_http_env_get_superglobal(ZEND_STRL("_POST"));
        object_init_ex(&zqs, php_http_querystring_get_class_entry());
        php_http_expect(SUCCESS == php_http_querystring_ctor(&zqs, zsg), unexpected_val, return);
-       zend_update_property(php_http_env_request_class_entry, getThis(), ZEND_STRL("form"), &zqs);
+       zend_update_property(php_http_env_request_class_entry, &obj->zo, ZEND_STRL("form"), &zqs);
        zval_ptr_dtor(&zqs);
 
        zsg = php_http_env_get_superglobal(ZEND_STRL("_COOKIE"));
        object_init_ex(&zqs, php_http_querystring_get_class_entry());
        php_http_expect(SUCCESS == php_http_querystring_ctor(&zqs, zsg), unexpected_val, return);
-       zend_update_property(php_http_env_request_class_entry, getThis(), ZEND_STRL("cookie"), &zqs);
+       zend_update_property(php_http_env_request_class_entry, &obj->zo, ZEND_STRL("cookie"), &zqs);
        zval_ptr_dtor(&zqs);
 
        array_init(&zqs);
        if ((zsg = php_http_env_get_superglobal(ZEND_STRL("_FILES")))) {
                zend_hash_apply_with_arguments(Z_ARRVAL_P(zsg), grab_files, 1, &zqs);
        }
-       zend_update_property(php_http_env_request_class_entry, getThis(), ZEND_STRL("files"), &zqs);
+       zend_update_property(php_http_env_request_class_entry, &obj->zo, ZEND_STRL("files"), &zqs);
        zval_ptr_dtor(&zqs);
 }
 
@@ -169,7 +169,7 @@ static PHP_METHOD(HttpEnvRequest, __construct)
                zend_fcall_info_cache fcc; \
                zval rv, mn, *args = ecalloc(sizeof(zval), ZEND_NUM_ARGS()); \
                zval *this_ptr = getThis(); \
-               zval qs_tmp, *qs = zend_read_property(Z_OBJCE_P(this_ptr), this_ptr, ZEND_STRL(prop), 0, &qs_tmp); \
+               zval qs_tmp, *qs = zend_read_property(Z_OBJCE_P(this_ptr), Z_OBJ_P(this_ptr), ZEND_STRL(prop), 0, &qs_tmp); \
                 \
                ZVAL_NULL(&rv); \
                array_init(&mn); \
@@ -197,7 +197,7 @@ static PHP_METHOD(HttpEnvRequest, getForm)
        if (ZEND_NUM_ARGS()) {
                call_querystring_get("form");
        } else {
-               zval zform_tmp, *zform = zend_read_property(php_http_env_request_class_entry, getThis(), ZEND_STRL("form"), 0, &zform_tmp);
+               zval zform_tmp, *zform = zend_read_property(php_http_env_request_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("form"), 0, &zform_tmp);
                RETURN_ZVAL(zform, 1, 0);
        }
 }
@@ -213,7 +213,7 @@ static PHP_METHOD(HttpEnvRequest, getQuery)
        if (ZEND_NUM_ARGS()) {
                call_querystring_get("query");
        } else {
-               zval zquery_tmp, *zquery = zend_read_property(php_http_env_request_class_entry, getThis(), ZEND_STRL("query"), 0, &zquery_tmp);
+               zval zquery_tmp, *zquery = zend_read_property(php_http_env_request_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("query"), 0, &zquery_tmp);
                RETURN_ZVAL(zquery, 1, 0);
        }
 }
@@ -229,7 +229,7 @@ static PHP_METHOD(HttpEnvRequest, getCookie)
        if (ZEND_NUM_ARGS()) {
                call_querystring_get("cookie");
        } else {
-               zval zcookie_tmp, *zcookie = zend_read_property(php_http_env_request_class_entry, getThis(), ZEND_STRL("cookie"), 0, &zcookie_tmp);
+               zval zcookie_tmp, *zcookie = zend_read_property(php_http_env_request_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("cookie"), 0, &zcookie_tmp);
                RETURN_ZVAL(zcookie, 1, 0);
        }
 }
@@ -239,7 +239,7 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpEnvRequest, getFiles)
 {
        if (SUCCESS == zend_parse_parameters_none()) {
-               zval zfiles_tmp, *zfiles = zend_read_property(php_http_env_request_class_entry, getThis(), ZEND_STRL("files"), 0, &zfiles_tmp);
+               zval zfiles_tmp, *zfiles = zend_read_property(php_http_env_request_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("files"), 0, &zfiles_tmp);
                RETURN_ZVAL(zfiles, 1, 0);
        }
 }
index f5d2da9846c6d4958df30e7db6c5170a79a0d780..3dba5b9b116533c99a8e61ce5981370089d209d7 100644 (file)
@@ -18,21 +18,21 @@ static void set_option(zval *options, const char *name_str, size_t name_len, int
                if (EXPECTED(value_ptr)) {
                        switch (type) {
                                case IS_DOUBLE:
-                                       zend_update_property_double(Z_OBJCE_P(options), options, name_str, name_len, *(double *)value_ptr);
+                                       zend_update_property_double(Z_OBJCE_P(options), Z_OBJ_P(options), name_str, name_len, *(double *)value_ptr);
                                        break;
                                case IS_LONG:
-                                       zend_update_property_long(Z_OBJCE_P(options), options, name_str, name_len, *(zend_long *)value_ptr);
+                                       zend_update_property_long(Z_OBJCE_P(options), Z_OBJ_P(options), name_str, name_len, *(zend_long *)value_ptr);
                                        break;
                                case IS_STRING:
-                                       zend_update_property_stringl(Z_OBJCE_P(options), options, name_str, name_len, value_ptr, value_len);
+                                       zend_update_property_stringl(Z_OBJCE_P(options), Z_OBJ_P(options), name_str, name_len, value_ptr, value_len);
                                        break;
                                case IS_ARRAY:
                                case IS_OBJECT:
-                                       zend_update_property(Z_OBJCE_P(options), options, name_str, name_len, value_ptr);
+                                       zend_update_property(Z_OBJCE_P(options), Z_OBJ_P(options), name_str, name_len, value_ptr);
                                        break;
                        }
                } else {
-                       zend_update_property_null(Z_OBJCE_P(options), options, name_str, name_len);
+                       zend_update_property_null(Z_OBJCE_P(options), Z_OBJ_P(options), name_str, name_len);
                }
        } else {
                convert_to_array(options);
@@ -65,7 +65,7 @@ static zval *get_option(zval *options, const char *name_str, size_t name_len, zv
        zval *val = NULL;
 
        if (EXPECTED(Z_TYPE_P(options) == IS_OBJECT)) {
-               val = zend_read_property(Z_OBJCE_P(options), options, name_str, name_len, 0, tmp);
+               val = zend_read_property(Z_OBJCE_P(options), Z_OBJ_P(options), name_str, name_len, 0, tmp);
        } else if (EXPECTED(Z_TYPE_P(options) == IS_ARRAY)) {
                val = zend_symtable_str_find(Z_ARRVAL_P(options), name_str, name_len);
        } else {
@@ -363,12 +363,12 @@ static ZEND_RESULT_CODE php_http_env_response_send_head(php_http_env_response_t
                php_http_version_t v;
                zend_string *zs = zval_get_string(zoption);
 
-               zval_ptr_dtor(zoption);
                if (EXPECTED(zs->len && php_http_version_parse(&v, zs->val))) {
                        ret = r->ops->set_protocol_version(r, &v);
                        php_http_version_dtor(&v);
                }
                zend_string_release(zs);
+               zval_ptr_dtor(zoption);
        }
 
        if (ret != SUCCESS) {
@@ -1205,7 +1205,7 @@ static PHP_METHOD(HttpEnvResponse, setContentDisposition)
 
        php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "a", &zdisposition), invalid_arg, return);
 
-       zend_update_property(Z_OBJCE_P(getThis()), getThis(), ZEND_STRL("contentDisposition"), zdisposition);
+       zend_update_property(Z_OBJCE_P(ZEND_THIS), Z_OBJ_P(ZEND_THIS), ZEND_STRL("contentDisposition"), zdisposition);
        RETVAL_ZVAL(getThis(), 1, 0);
 }
 
index 048af87c8b63a60fd881a0cb319b3637f64f6549..eb3b5e35b11527f30a84b305c4308b17354c3b7b 100644 (file)
 
 #include "php_http_api.h"
 
-#if PHP_HTTP_HAVE_HASH
-#      include "ext/hash/php_hash.h"
-#endif
-
+#include "ext/hash/php_hash.h"
 #include "ext/standard/crc32.h"
 #include "ext/standard/sha1.h"
 #include "ext/standard/md5.h"
 
 php_http_etag_t *php_http_etag_init(const char *mode)
 {
-       void *ctx;
        php_http_etag_t *e;
+       zend_string *mode_str = zend_string_init(mode, strlen(mode), 0);
+       const php_hash_ops *eho = php_hash_fetch_ops(mode_str);
 
-       if (mode && (!strcasecmp(mode, "crc32b"))) {
-               ctx = emalloc(sizeof(uint32_t));
-               *((uint32_t *) ctx) = ~0;
-       } else if (mode && !strcasecmp(mode, "sha1")) {
-               PHP_SHA1Init(ctx = emalloc(sizeof(PHP_SHA1_CTX)));
-       } else if (mode && !strcasecmp(mode, "md5")) {
-               PHP_MD5Init(ctx = emalloc(sizeof(PHP_MD5_CTX)));
-       } else {
-#if PHP_HTTP_HAVE_HASH
-               const php_hash_ops *eho = NULL;
-
-               if (mode && (eho = php_hash_fetch_ops(mode, strlen(mode)))) {
-                       ctx = emalloc(eho->context_size);
-                       eho->hash_init(ctx);
-               } else
-#endif
+       if (!eho) {
+               zend_string_release(mode_str);
                return NULL;
        }
+       zend_string_release(mode_str);
 
-       e = emalloc(sizeof(*e));
-       e->ctx = ctx;
-       e->mode = estrdup(mode);
+       e = emalloc(sizeof(*e) + eho->context_size - 1);
+       e->ops = eho;
+       eho->hash_init(e->ctx);
 
        return e;
 }
@@ -54,32 +39,10 @@ php_http_etag_t *php_http_etag_init(const char *mode)
 char *php_http_etag_finish(php_http_etag_t *e)
 {
        unsigned char digest[128] = {0};
-       char *etag = NULL;
+       char *etag;
 
-       if (!strcasecmp(e->mode, "crc32b")) {
-               uint32_t e_ctx;
-               memcpy(&e_ctx, e->ctx, 4);
-               e_ctx = ntohl(~e_ctx);
-               etag = php_http_etag_digest((unsigned char *) &e_ctx, 4);
-       } else if ((!strcasecmp(e->mode, "sha1"))) {
-               PHP_SHA1Final(digest, e->ctx);
-               etag = php_http_etag_digest(digest, 20);
-       } else if ((!strcasecmp(e->mode, "md5"))) {
-               PHP_MD5Final(digest, e->ctx);
-               etag = php_http_etag_digest(digest, 16);
-       } else {
-#if PHP_HTTP_HAVE_HASH
-               const php_hash_ops *eho = NULL;
-
-               if ((eho = php_hash_fetch_ops(e->mode, strlen(e->mode)))) {
-                       eho->hash_final(digest, e->ctx);
-                       etag = php_http_etag_digest(digest, eho->digest_size);
-               }
-#endif
-       }
-
-       efree(e->ctx);
-       efree(e->mode);
+       e->ops->hash_final(digest, e->ctx);
+       etag = php_http_etag_digest(digest, e->ops->digest_size);
        efree(e);
 
        return etag;
@@ -87,25 +50,7 @@ char *php_http_etag_finish(php_http_etag_t *e)
 
 size_t php_http_etag_update(php_http_etag_t *e, const char *data_ptr, size_t data_len)
 {
-       if (!strcasecmp(e->mode, "crc32b")) {
-               uint32_t i, c = *((uint32_t *) e->ctx);
-               for (i = 0; i < data_len; ++i) {
-                       CRC32(c, data_ptr[i]);
-               }
-               *((uint32_t *) e->ctx) = c;
-       } else if ((!strcasecmp(e->mode, "sha1"))) {
-               PHP_SHA1Update(e->ctx, (const unsigned char *) data_ptr, data_len);
-       } else if ((!strcasecmp(e->mode, "md5"))) {
-               PHP_MD5Update(e->ctx, (const unsigned char *) data_ptr, data_len);
-       } else {
-#if PHP_HTTP_HAVE_HASH
-               const php_hash_ops *eho = NULL;
-
-               if ((eho = php_hash_fetch_ops(e->mode, strlen(e->mode)))) {
-                       eho->hash_update(e->ctx, (const unsigned char *) data_ptr, data_len);
-               }
-#endif
-       }
+       e->ops->hash_update(e->ctx, (const unsigned char *) data_ptr, data_len);
 
        return data_len;
 }
index f208db7a48a685f1784adeaa52380a0da082e42f..338506c4445ffad42ca6ee24425d922a165eb26c 100644 (file)
 #ifndef PHP_HTTP_ETAG_H
 #define PHP_HTTP_ETAG_H
 
+#include "ext/hash/php_hash.h"
+
 typedef struct php_http_etag {
-       void *ctx;
-       char *mode;
+       const php_hash_ops *ops;
+       char ctx[1];
 } php_http_etag_t;
 
 PHP_HTTP_API php_http_etag_t *php_http_etag_init(const char *mode);
index 4c9a7025684051ade431db1f730cff99083bbd11..76b2f68a374e197cab53b4a4cb0414bbc39e3d7e 100644 (file)
@@ -183,11 +183,11 @@ PHP_METHOD(HttpHeader, __construct)
 
        if (name_str && name_len) {
                char *pretty_str = estrndup(name_str, name_len);
-               zend_update_property_stringl(php_http_header_class_entry, getThis(), ZEND_STRL("name"), php_http_pretty_key(pretty_str, name_len, 1, 1), name_len);
+               zend_update_property_stringl(php_http_header_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("name"), php_http_pretty_key(pretty_str, name_len, 1, 1), name_len);
                efree(pretty_str);
        }
        if (value_str && value_len) {
-               zend_update_property_stringl(php_http_header_class_entry, getThis(), ZEND_STRL("value"), value_str, value_len);
+               zend_update_property_stringl(php_http_header_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("value"), value_str, value_len);
        }
 }
 
@@ -201,11 +201,11 @@ PHP_METHOD(HttpHeader, serialize)
                zval name_tmp, value_tmp;
 
                php_http_buffer_init(&buf);
-               zs = zval_get_string(zend_read_property(php_http_header_class_entry, getThis(), ZEND_STRL("name"), 0, &name_tmp));
+               zs = zval_get_string(zend_read_property(php_http_header_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("name"), 0, &name_tmp));
                php_http_buffer_appendz(&buf, zs);
                zend_string_release(zs);
 
-               zs = zval_get_string(zend_read_property(php_http_header_class_entry, getThis(), ZEND_STRL("value"), 0, &value_tmp));
+               zs = zval_get_string(zend_read_property(php_http_header_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("value"), 0, &value_tmp));
                if (zs->len) {
                        php_http_buffer_appends(&buf, ": ");
                        php_http_buffer_appendz(&buf, zs);
@@ -239,16 +239,16 @@ PHP_METHOD(HttpHeader, unserialize)
                                zend_hash_internal_pointer_reset(&ht);
                                switch (zend_hash_get_current_key(&ht, &key, &idx)) {
                                        case HASH_KEY_IS_STRING:
-                                               zend_update_property_str(php_http_header_class_entry, getThis(), ZEND_STRL("name"), key);
+                                               zend_update_property_str(php_http_header_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("name"), key);
                                                break;
                                        case HASH_KEY_IS_LONG:
-                                               zend_update_property_long(php_http_header_class_entry, getThis(), ZEND_STRL("name"), idx);
+                                               zend_update_property_long(php_http_header_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("name"), idx);
                                                break;
                                        default:
                                                break;
                                }
                                zs = zval_get_string(zend_hash_get_current_data(&ht));
-                               zend_update_property_str(php_http_header_class_entry, getThis(), ZEND_STRL("value"), zs);
+                               zend_update_property_str(php_http_header_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("value"), zs);
                                zend_string_release(zs);
                        }
                }
@@ -273,7 +273,7 @@ PHP_METHOD(HttpHeader, match)
                return;
        }
 
-       zs = zval_get_string(zend_read_property(php_http_header_class_entry, getThis(), ZEND_STRL("value"), 0, &value_tmp));
+       zs = zval_get_string(zend_read_property(php_http_header_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("value"), 0, &value_tmp));
        RETVAL_BOOL(php_http_match(zs->val, val_str, flags));
        zend_string_release(zs);
 }
@@ -299,7 +299,7 @@ PHP_METHOD(HttpHeader, negotiate)
                array_init(rs_array);
        }
 
-       zs = zval_get_string(zend_read_property(php_http_header_class_entry, getThis(), ZEND_STRL("name"), 0, &name_tmp));
+       zs = zval_get_string(zend_read_property(php_http_header_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("name"), 0, &name_tmp));
        if (zend_string_equals_literal(zs, "Accept")) {
                sep_str = "/";
                sep_len = 1;
@@ -309,7 +309,7 @@ PHP_METHOD(HttpHeader, negotiate)
        }
        zend_string_release(zs);
 
-       zs = zval_get_string(zend_read_property(php_http_header_class_entry, getThis(), ZEND_STRL("value"), 0, &value_tmp));
+       zs = zval_get_string(zend_read_property(php_http_header_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("value"), 0, &value_tmp));
        if ((rs = php_http_negotiate(zs->val, zs->len, supported, sep_str, sep_len))) {
                PHP_HTTP_DO_NEGOTIATE_HANDLE_RESULT(rs, supported, rs_array);
        } else {
@@ -333,7 +333,7 @@ PHP_METHOD(HttpHeader, getParams)
        object_init_ex(&zparams_obj, php_http_params_get_class_entry());
        
        zargs = (zval *) ecalloc(ZEND_NUM_ARGS()+1, sizeof(zval));
-       ZVAL_COPY_VALUE(&zargs[0], zend_read_property(php_http_header_class_entry, getThis(), ZEND_STRL("value"), 0, &value_tmp));
+       ZVAL_COPY_VALUE(&zargs[0], zend_read_property(php_http_header_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("value"), 0, &value_tmp));
        if (ZEND_NUM_ARGS()) {
                zend_get_parameters_array(ZEND_NUM_ARGS(), ZEND_NUM_ARGS(), &zargs[1]);
        }
@@ -381,7 +381,7 @@ PHP_METHOD(HttpHeader, parse)
 
                                        object_init_ex(&zho, ce);
                                        Z_TRY_ADDREF_P(val);
-                                       zend_call_method_with_2_params(&zho, ce, NULL, "__construct", NULL, &zkey, val);
+                                       zend_call_method_with_2_params(Z_OBJ(zho), ce, NULL, "__construct", NULL, &zkey, val);
                                        zval_ptr_dtor(val);
                                        zval_ptr_dtor(&zkey);
 
index cd76b763cc6b4642c2256265077480d830c67ab9..6700c496865d62cb7f7bbc1d1d33455921cc55d7 100644 (file)
@@ -40,7 +40,13 @@ php_http_header_parser_t *php_http_header_parser_init(php_http_header_parser_t *
        return parser;
 }
 
-#define php_http_header_parser_state_push(parser, state) zend_ptr_stack_push(&(parser)->stack, (void *) (state)), (state)
+static inline php_http_header_parser_state_t
+php_http_header_parser_state_push(php_http_header_parser_t *parser, php_http_header_parser_state_t state)
+{
+       zend_ptr_stack_push(&(parser)->stack, (void *) (state));
+       return state;
+}
+
 #define php_http_header_parser_state_ex(parser) ((parser)->stack.top \
                ? (php_http_header_parser_state_t) (parser)->stack.elements[(parser)->stack.top - 1] \
                : PHP_HTTP_HEADER_PARSER_STATE_START)
@@ -428,7 +434,7 @@ static zend_function_entry php_http_header_parser_methods[] = {
                PHP_ME(HttpHeaderParser, getState, ai_HttpHeaderParser_getState, ZEND_ACC_PUBLIC)
                PHP_ME(HttpHeaderParser, parse, ai_HttpHeaderParser_parse, ZEND_ACC_PUBLIC)
                PHP_ME(HttpHeaderParser, stream, ai_HttpHeaderParser_stream, ZEND_ACC_PUBLIC)
-               {NULL, NULL, NULL}
+               {0}
 };
 
 PHP_MINIT_FUNCTION(http_header_parser)
index 2cce701879e2e86626c2703cdcbb4b3de91dae86..1bbc53cefce10150da3d7d03de434c19bec48895 100644 (file)
@@ -332,7 +332,7 @@ static void message_headers(php_http_message_t *msg, php_http_buffer_t *str)
        char *tmp = NULL;
        size_t len = 0;
 
-       php_http_info_to_string((php_http_info_t *) msg, &tmp, &len, PHP_HTTP_CRLF TSRMLS_CC);
+       php_http_info_to_string((php_http_info_t *) msg, &tmp, &len, PHP_HTTP_CRLF);
        php_http_message_update_headers(msg);
 
        php_http_buffer_append(str, tmp, len);
@@ -509,9 +509,8 @@ zend_class_entry *php_http_message_get_class_entry(void)
        return php_http_message_class_entry;
 }
 
-static zval *php_http_message_object_read_prop(zval *object, zval *member, int type, void **cache_slot, zval *rv);
-
-static PHP_WRITE_PROP_HANDLER_TYPE php_http_message_object_write_prop(zval *object, zval *member, zval *value, void **cache_slot);
+static zval *php_http_message_object_read_prop(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv);
+static zval *php_http_message_object_write_prop(zend_object *object, zend_string *member, zval *value, void **cache_slot);
 
 static zend_object_handlers php_http_message_object_handlers;
 static HashTable php_http_message_object_prophandlers;
@@ -857,10 +856,10 @@ php_http_message_object_t *php_http_message_object_new_ex(zend_class_entry *ce,
        return o;
 }
 
-zend_object *php_http_message_object_clone(zval *this_ptr)
+zend_object *php_http_message_object_clone(zend_object *this_ptr)
 {
        php_http_message_object_t *new_obj;
-       php_http_message_object_t *old_obj = PHP_HTTP_OBJ(NULL, this_ptr);
+       php_http_message_object_t *old_obj = PHP_HTTP_OBJ(this_ptr, NULL);
 
        new_obj = php_http_message_object_new_ex(old_obj->zo.ce, php_http_message_copy(old_obj->message, NULL));
        zend_objects_clone_members(&new_obj->zo, &old_obj->zo);
@@ -895,53 +894,45 @@ void php_http_message_object_free(zend_object *object)
        zend_object_std_dtor(object);
 }
 
-#if PHP_VERSION_ID >= 70400
-static zval *php_http_message_object_get_prop_ptr(zval *object, zval *member, int type, void **cache_slot)
+static zval *php_http_message_object_get_prop_ptr(zend_object *object, zend_string *member, int type, void **cache_slot)
 {
        return NULL;
 }
-#endif
 
-static zval *php_http_message_object_read_prop(zval *object, zval *member, int type, void **cache_slot, zval *tmp)
+static zval *php_http_message_object_read_prop(zend_object *object, zend_string *member, int type, void **cache_slot, zval *tmp)
 {
        zval *return_value;
-       zend_string *member_name = zval_get_string(member);
-       php_http_message_object_prophandler_t *handler = php_http_message_object_get_prophandler(member_name);
+       php_http_message_object_prophandler_t *handler = php_http_message_object_get_prophandler(member);
 
        return_value = zend_get_std_object_handlers()->read_property(object, member, type, cache_slot, tmp);
 
        if (handler && handler->read) {
-               php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, object);
+               php_http_message_object_t *obj = PHP_HTTP_OBJ(object, NULL);
 
                handler->read(obj, return_value);
        }
-
-       zend_string_release(member_name);
        return return_value;
 }
 
-static PHP_WRITE_PROP_HANDLER_TYPE php_http_message_object_write_prop(zval *object, zval *member, zval *value, void **cache_slot)
+static zval *php_http_message_object_write_prop(zend_object *object, zend_string *member, zval *value, void **cache_slot)
 {
-       php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, object);
+       php_http_message_object_t *obj = PHP_HTTP_OBJ(object, NULL);
        php_http_message_object_prophandler_t *handler;
-       zend_string *member_name = zval_get_string(member);
 
        PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 
-       if ((handler = php_http_message_object_get_prophandler(member_name))) {
+       if ((handler = php_http_message_object_get_prophandler(member))) {
                handler->write(obj, value);
        } else {
                zend_get_std_object_handlers()->write_property(object, member, value, cache_slot);
        }
-
-       zend_string_release(member_name);
-       PHP_WRITE_PROP_HANDLER_RETURN(value);
+       return value;
 }
 
-static HashTable *php_http_message_object_get_debug_info(zval *object, int *is_temp)
+static HashTable *php_http_message_object_get_debug_info(zend_object *object, int *is_temp)
 {
        zval tmp;
-       php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, object);
+       php_http_message_object_t *obj = PHP_HTTP_OBJ(object, NULL);
        HashTable *props = zend_get_std_object_handlers()->get_properties(object);
        char *ver_str, *url_str = NULL;
        size_t ver_len, url_len = 0;
@@ -1017,10 +1008,10 @@ static HashTable *php_http_message_object_get_debug_info(zval *object, int *is_t
        return props;
 }
 
-static HashTable *php_http_message_object_get_gc(zval *object, zval **table, int *n)
+static HashTable *php_http_message_object_get_gc(zend_object *object, zval **table, int *n)
 {
-       php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, object);
-       HashTable *props = Z_OBJPROP_P(object);
+       php_http_message_object_t *obj = PHP_HTTP_OBJ(object, NULL);
+       HashTable *props = object->handlers->get_properties(object);
        uint32_t count = 2 + zend_hash_num_elements(props);
        zval *val;
 
@@ -1043,6 +1034,30 @@ static HashTable *php_http_message_object_get_gc(zval *object, zval **table, int
        return NULL;
 }
 
+static int php_http_message_object_cast(zend_object *object, zval *return_value, int type)
+{
+       php_http_message_object_t *obj = PHP_HTTP_OBJ(object, NULL);
+       char *string;
+       size_t length;
+
+       switch (type) {
+       case IS_STRING:
+               PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
+               php_http_message_to_string(obj->message, &string, &length);
+               if (string) {
+                       RETVAL_STR(php_http_cs2zs(string, length));
+               } else {
+                       RETVAL_EMPTY_STRING();
+               }
+               return SUCCESS;
+       case _IS_BOOL:
+               RETVAL_TRUE;
+               return SUCCESS;
+       default:
+               return FAILURE;
+       }
+}
+
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage___construct, 0, 0, 0)
        ZEND_ARG_INFO(0, message)
        ZEND_ARG_INFO(0, greedy)
@@ -2066,6 +2081,7 @@ PHP_MINIT_FUNCTION(http_message)
        php_http_message_object_handlers.get_property_ptr_ptr = NULL;
 #endif
        php_http_message_object_handlers.get_gc = php_http_message_object_get_gc;
+       php_http_message_object_handlers.cast_object = php_http_message_object_cast;
 
        zend_class_implements(php_http_message_class_entry, 3, spl_ce_Countable, zend_ce_serializable, zend_ce_iterator);
 
index 538cdb1730b4406b4ba93042f9a9731bd9e9141c..d0b604f054653c80cb10222d5b951f021c47557a 100644 (file)
@@ -104,7 +104,7 @@ ZEND_RESULT_CODE php_http_message_object_init_body_object(php_http_message_objec
 
 zend_object *php_http_message_object_new(zend_class_entry *ce);
 php_http_message_object_t *php_http_message_object_new_ex(zend_class_entry *ce, php_http_message_t *msg);
-zend_object *php_http_message_object_clone(zval *object);
+zend_object *php_http_message_object_clone(zend_object *object);
 void php_http_message_object_free(zend_object *object);
 
 #endif
index 97b1a148bf3ae87c9b3984530cd563b3b7133b55..ad8a2b12f7827c80ffac690ae392d4c3ccc67ebc 100644 (file)
@@ -432,7 +432,7 @@ static ZEND_RESULT_CODE add_recursive_files(php_http_message_body_t *body, const
                        return FAILURE;
                } else {
                        zend_string *znc = zval_get_string(zname), *ztc = zval_get_string(ztype);
-                       php_http_arrkey_t arrkey = {0, znc};
+                       php_http_arrkey_t arrkey = {0, znc, 0, 0};
                        char *key = format_key(&arrkey, name);
                        ZEND_RESULT_CODE ret = php_http_message_body_add_form_file(body, key, ztc->val, zfc->val, stream);
 
@@ -590,10 +590,10 @@ php_http_message_body_object_t *php_http_message_body_object_new_ex(zend_class_e
        return o;
 }
 
-zend_object *php_http_message_body_object_clone(zval *object)
+zend_object *php_http_message_body_object_clone(zend_object *object)
 {
        php_http_message_body_object_t *new_obj;
-       php_http_message_body_object_t *old_obj = PHP_HTTP_OBJ(NULL, object);
+       php_http_message_body_object_t *old_obj = PHP_HTTP_OBJ(object, NULL);
        php_http_message_body_t *body = php_http_message_body_copy(old_obj->body, NULL);
 
        new_obj = php_http_message_body_object_new_ex(old_obj->zo.ce, body);
@@ -602,10 +602,10 @@ zend_object *php_http_message_body_object_clone(zval *object)
        return &new_obj->zo;
 }
 
-static HashTable *php_http_message_body_object_get_gc(zval *object, zval **table, int *n)
+static HashTable *php_http_message_body_object_get_gc(zend_object *object, zval **table, int *n)
 {
-       php_http_message_body_object_t *obj = PHP_HTTP_OBJ(NULL, object);
-       HashTable *props = Z_OBJPROP_P(object);
+       php_http_message_body_object_t *obj = PHP_HTTP_OBJ(object, NULL);
+       HashTable *props = object->handlers->get_properties(object);
        uint32_t count = zend_hash_num_elements(props);
 
        obj->gc = erealloc(obj->gc, (1 + count) * sizeof(zval));
index d4115f54a07450ebbe81ef8449e20ddfe29e123a..81566f2c1625236e1021a9e99913e48ae2b16cc6 100644 (file)
@@ -71,7 +71,7 @@ PHP_MINIT_FUNCTION(http_message_body);
 
 zend_object *php_http_message_body_object_new(zend_class_entry *ce);
 php_http_message_body_object_t *php_http_message_body_object_new_ex(zend_class_entry *ce, php_http_message_body_t *body);
-zend_object *php_http_message_body_object_clone(zval *object);
+zend_object *php_http_message_body_object_clone(zend_object *object);
 void php_http_message_body_object_free(zend_object *object);
 
 #endif
index 517806d12cf139bee4db2e8046a485a138bfbe2f..55087e0f440ed628de9b26d3f38e347d6ebe6930 100644 (file)
@@ -57,7 +57,13 @@ php_http_message_parser_t *php_http_message_parser_init(php_http_message_parser_
        return parser;
 }
 
-#define php_http_message_parser_state_push(parser, state) zend_ptr_stack_push(&(parser)->stack, (void *) (state)), (state)
+static inline php_http_message_parser_state_t
+php_http_message_parser_state_push(php_http_message_parser_t *parser, php_http_message_parser_state_t state)
+{
+       zend_ptr_stack_push(&parser->stack, (void *) state);
+       return state;
+}
+
 #define php_http_message_parser_state_pop(parser) ((parser)->stack.top \
                ? (php_http_message_parser_state_t) zend_ptr_stack_pop(&parser->stack) \
                : PHP_HTTP_MESSAGE_PARSER_STATE_START)
@@ -644,7 +650,7 @@ static zend_function_entry php_http_message_parser_methods[] = {
                PHP_ME(HttpMessageParser, getState, ai_HttpMessageParser_getState, ZEND_ACC_PUBLIC)
                PHP_ME(HttpMessageParser, parse, ai_HttpMessageParser_parse, ZEND_ACC_PUBLIC)
                PHP_ME(HttpMessageParser, stream, ai_HttpMessageParser_stream, ZEND_ACC_PUBLIC)
-               {NULL, NULL, NULL}
+               {0}
 };
 
 PHP_MINIT_FUNCTION(http_message_parser)
index f0cc25fa32e0d2bf07eac0ef2295d839d009f741..261387f6bd6ffbecb01377d2ef87efe7fd936431 100644 (file)
@@ -261,10 +261,9 @@ size_t php_http_pass_fcall_callback(void *cb_arg, const char *str, size_t len)
        zval zdata;
 
        ZVAL_STRINGL(&zdata, str, len);
-       if (SUCCESS == zend_fcall_info_argn(&fcd->fci, 2, &fcd->fcz, &zdata)) {
-               zend_fcall_info_call(&fcd->fci, &fcd->fcc, NULL, NULL);
-               zend_fcall_info_args_clear(&fcd->fci, 0);
-       }
+       zend_fcall_info_argn(&fcd->fci, 2, &fcd->fcz, &zdata);
+       zend_fcall_info_call(&fcd->fci, &fcd->fcc, NULL, NULL);
+       zend_fcall_info_args_clear(&fcd->fci, 0);
        zval_ptr_dtor(&zdata);
        return len;
 }
index b91638e2098f27abb48c1abdd0bc53be3f58541a..99660ea98ada5caf0ddc74105c3e72d0b60a17a7 100644 (file)
@@ -99,46 +99,13 @@ static inline const char *php_http_locate_bin_eol(const char *bin, size_t len, i
 
 #if PHP_DEBUG
 #      undef  HASH_OF
-#      if PHP_VERSION_ID >= 70500
-#              define HASH_OF(p) ((HashTable*)(Z_TYPE_P(p)==IS_ARRAY ? Z_ARRVAL_P(p) : ((Z_TYPE_P(p)==IS_OBJECT ? Z_OBJ_HT_P(p)->get_properties(Z_OBJ_P(p)) : NULL))))
-#      else
-#              define HASH_OF(p) ((HashTable*)(Z_TYPE_P(p)==IS_ARRAY ? Z_ARRVAL_P(p) : ((Z_TYPE_P(p)==IS_OBJECT ? Z_OBJ_HT_P(p)->get_properties((p)) : NULL))))
-#      endif
+#      define HASH_OF(p) ((HashTable*)(Z_TYPE_P(p)==IS_ARRAY ? Z_ARRVAL_P(p) : ((Z_TYPE_P(p)==IS_OBJECT ? Z_OBJ_HT_P(p)->get_properties(Z_OBJ_P(p)) : NULL))))
 #endif
 
-#ifndef GC_SET_REFCOUNT
-#      define GC_SET_REFCOUNT(gc, rc) GC_REFCOUNT(gc) = rc
-#endif
-#ifndef GC_ADDREF
-#      define GC_ADDREF(gc) ++GC_REFCOUNT(gc)
-#endif
-#ifndef GC_DELREF
-#      define GC_DELREF(gc) --GC_REFCOUNT(gc)
-#endif
-
-#ifdef ZEND_HASH_GET_APPLY_COUNT
-#      define HT_IS_RECURSIVE(ht) (ZEND_HASH_GET_APPLY_COUNT(ht) > 0)
-#else
-#      define HT_IS_RECURSIVE(ht) GC_IS_RECURSIVE(ht)
-#endif
-#ifdef ZEND_HASH_INC_APPLY_COUNT
-#      define HT_PROTECT_RECURSION(ht) ZEND_HASH_INC_APPLY_COUNT(ht)
-#else
-#      define HT_PROTECT_RECURSION(ht) GC_PROTECT_RECURSION(ht)
-#endif
-#ifdef ZEND_HASH_DEC_APPLY_COUNT
-#      define HT_UNPROTECT_RECURSION(ht) ZEND_HASH_DEC_APPLY_COUNT(ht)
-#else
-#      define HT_UNPROTECT_RECURSION(ht) GC_UNPROTECT_RECURSION(ht)
-#endif
 
-#if PHP_VERSION_ID >= 70400
-#      define PHP_WRITE_PROP_HANDLER_TYPE zval *
-#      define PHP_WRITE_PROP_HANDLER_RETURN(v) return v
-#else
-#      define PHP_WRITE_PROP_HANDLER_TYPE void
-#      define PHP_WRITE_PROP_HANDLER_RETURN(v)
-#endif
+#define HT_IS_RECURSIVE(ht) GC_IS_RECURSIVE(ht)
+#define HT_PROTECT_RECURSION(ht) GC_PROTECT_RECURSION(ht)
+#define HT_UNPROTECT_RECURSION(ht) GC_UNPROTECT_RECURSION(ht)
 
 static inline void *PHP_HTTP_OBJ(zend_object *zo, zval *zv)
 {
@@ -150,16 +117,8 @@ static inline void *PHP_HTTP_OBJ(zend_object *zo, zval *zv)
 
 static inline zend_string *php_http_cs2zs(char *s, size_t l)
 {
-       zend_string *str = erealloc(s, sizeof(*str) + l);
-
-       memmove(str->val, str, l);
-       str->val[l] = 0;
-       str->len = l;
-       str->h = 0;
-
-       GC_SET_REFCOUNT(str, 1);
-       GC_TYPE_INFO(str) = IS_STRING;
-
+       zend_string *str = zend_string_init(s, l, 0);
+       efree(s);
        return str;
 }
 
@@ -180,9 +139,6 @@ static inline ZEND_RESULT_CODE php_http_ini_entry(const char *name_str, size_t n
        return FAILURE;
 }
 
-#define Z_ISUSER(zv) (Z_TYPE(zv) <= 10)
-#define Z_ISUSER_P(zvp) Z_ISUSER(*(zvp))
-
 /* return object(values) */
 #define ZVAL_OBJECT(z, o, addref) \
        ZVAL_OBJ(z, o); \
index cd09d3740f6dc8e293b72b3dbb742b096cca58ca..3a5548ea0de0b35d9b54e5d616d652a4e920da7d 100644 (file)
@@ -16,9 +16,8 @@
 # define PHP_HTTP_DEBUG_NEG 0
 #endif
 
-static int php_http_negotiate_sort(const void *first, const void *second)
+static int php_http_negotiate_sort(Bucket *b1, Bucket *b2)
 {
-       Bucket *b1 = (Bucket *) first, *b2 = (Bucket *) second;
        int result = numeric_compare_function(&b1->val, &b2->val);
 
        return (result > 0 ? -1 : (result < 0 ? 1 : 0));
index 65a27afd27abcd57d291de8ecb69ead8aeed2d6f..94d703e07be583af3aae4bb19d592fca2ec0a08b 100644 (file)
@@ -16,7 +16,7 @@ static void php_http_options_hash_dtor(zval *pData)
 {
        php_http_option_t *opt = Z_PTR_P(pData);
 
-       zval_internal_dtor(&opt->defval);
+       zval_internal_ptr_dtor(&opt->defval);
        zend_hash_destroy(&opt->suboptions.options);
        zend_string_release(opt->name);
        pefree(opt, opt->persistent);
index 92c144154c8866d4af009ded0ef893eea51ed240..44f01c32992df9b872f8bddcf28c6a5c846e9d0a 100644 (file)
@@ -20,7 +20,7 @@ static php_http_params_opts_t def_opts = {
        def_param_sep_ptr,
        def_arg_sep_ptr,
        def_val_sep_ptr,
-       {{0}},
+       {{0}, {0}, {0}},
        PHP_HTTP_PARAMS_DEFAULT
 };
 
@@ -677,8 +677,9 @@ static void skip_sep(size_t skip, php_http_params_state_t *state, php_http_param
 
 HashTable *php_http_params_parse(HashTable *params, const php_http_params_opts_t *opts)
 {
-       php_http_params_state_t state = {{NULL,0}, {NULL,0}, {NULL,0}, {NULL,0}, {NULL,NULL,NULL}, 0, 0};
+       php_http_params_state_t state;
 
+       memset(&state, 0, sizeof(state));
        state.input.str = opts->input.str;
        state.input.len = opts->input.len;
 
@@ -1068,16 +1069,16 @@ PHP_METHOD(HttpParams, __construct)
        {
                switch (ZEND_NUM_ARGS()) {
                        case 5:
-                               zend_update_property_long(php_http_params_class_entry, getThis(), ZEND_STRL("flags"), flags);
+                               zend_update_property_long(php_http_params_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("flags"), flags);
                                /* no break */
                        case 4:
-                               zend_update_property(php_http_params_class_entry, getThis(), ZEND_STRL("val_sep"), val_sep);
+                               zend_update_property(php_http_params_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("val_sep"), val_sep);
                                /* no break */
                        case 3:
-                               zend_update_property(php_http_params_class_entry, getThis(), ZEND_STRL("arg_sep"), arg_sep);
+                               zend_update_property(php_http_params_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("arg_sep"), arg_sep);
                                /* no break */
                        case 2:
-                               zend_update_property(php_http_params_class_entry, getThis(), ZEND_STRL("param_sep"), param_sep);
+                               zend_update_property(php_http_params_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("param_sep"), param_sep);
                                /* no break */
                }
 
@@ -1086,7 +1087,7 @@ PHP_METHOD(HttpParams, __construct)
                                case IS_OBJECT:
                                case IS_ARRAY:
                                        convert_to_array(zparams);
-                                       zend_update_property(php_http_params_class_entry, getThis(), ZEND_STRL("params"), zparams);
+                                       zend_update_property(php_http_params_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("params"), zparams);
                                        break;
                                default:
                                        zs = zval_get_string(zparams);
@@ -1095,15 +1096,15 @@ PHP_METHOD(HttpParams, __construct)
 
                                                php_http_params_opts_t opts = {
                                                        {zs->val, zs->len},
-                                                       php_http_params_separator_init(zend_read_property(php_http_params_class_entry, getThis(), ZEND_STRL("param_sep"), 0, &tmp)),
-                                                       php_http_params_separator_init(zend_read_property(php_http_params_class_entry, getThis(), ZEND_STRL("arg_sep"), 0, &tmp)),
-                                                       php_http_params_separator_init(zend_read_property(php_http_params_class_entry, getThis(), ZEND_STRL("val_sep"), 0, &tmp)),
-                                                       {{0}}, flags
+                                                       php_http_params_separator_init(zend_read_property(php_http_params_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("param_sep"), 0, &tmp)),
+                                                       php_http_params_separator_init(zend_read_property(php_http_params_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("arg_sep"), 0, &tmp)),
+                                                       php_http_params_separator_init(zend_read_property(php_http_params_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("val_sep"), 0, &tmp)),
+                                                       {{0}, {0}, {0}}, flags
                                                };
 
                                                array_init(&tmp);
                                                php_http_params_parse(Z_ARRVAL(tmp), &opts);
-                                               zend_update_property(php_http_params_class_entry, getThis(), ZEND_STRL("params"), &tmp);
+                                               zend_update_property(php_http_params_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("params"), &tmp);
                                                zval_ptr_dtor(&tmp);
 
                                                php_http_params_separator_free(opts.param);
@@ -1117,7 +1118,7 @@ PHP_METHOD(HttpParams, __construct)
                        zval tmp;
 
                        array_init(&tmp);
-                       zend_update_property(php_http_params_class_entry, getThis(), ZEND_STRL("params"), &tmp);
+                       zend_update_property(php_http_params_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("params"), &tmp);
                        zval_ptr_dtor(&tmp);
                }
        }
@@ -1133,7 +1134,7 @@ PHP_METHOD(HttpParams, toArray)
        if (SUCCESS != zend_parse_parameters_none()) {
                return;
        }
-       zparams = zend_read_property(php_http_params_class_entry, getThis(), ZEND_STRL("params"), 0, &zparams_tmp);
+       zparams = zend_read_property(php_http_params_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("params"), 0, &zparams_tmp);
        RETURN_ZVAL(zparams, 1, 0);
 }
 
@@ -1147,23 +1148,23 @@ PHP_METHOD(HttpParams, toString)
        long flags;
        php_http_buffer_t buf;
 
-       zparams = zend_read_property(php_http_params_class_entry, getThis(), ZEND_STRL("params"), 0, &zparams_tmp);
+       zparams = zend_read_property(php_http_params_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("params"), 0, &zparams_tmp);
        convert_to_array_ex(zparams);
-       flags = zval_get_long(zend_read_property(php_http_params_class_entry, getThis(), ZEND_STRL("flags"), 0, &flags_tmp));
+       flags = zval_get_long(zend_read_property(php_http_params_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("flags"), 0, &flags_tmp));
 
-       zpsep = zend_read_property(php_http_params_class_entry, getThis(), ZEND_STRL("param_sep"), 0, &psep_tmp);
+       zpsep = zend_read_property(php_http_params_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("param_sep"), 0, &psep_tmp);
        if (Z_TYPE_P(zpsep) == IS_ARRAY && (tmp = zend_hash_get_current_data(Z_ARRVAL_P(zpsep)))) {
                psep = zval_get_string(tmp);
        } else {
                psep = zval_get_string(zpsep);
        }
-       zasep = zend_read_property(php_http_params_class_entry, getThis(), ZEND_STRL("arg_sep"), 0, &asep_tmp);
+       zasep = zend_read_property(php_http_params_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("arg_sep"), 0, &asep_tmp);
        if (Z_TYPE_P(zasep) == IS_ARRAY && (tmp = zend_hash_get_current_data(Z_ARRVAL_P(zasep)))) {
                asep = zval_get_string(tmp);
        } else {
                asep = zval_get_string(zasep);
        }
-       zvsep = zend_read_property(php_http_params_class_entry, getThis(), ZEND_STRL("val_sep"), 0, &vsep_tmp);
+       zvsep = zend_read_property(php_http_params_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("val_sep"), 0, &vsep_tmp);
        if (Z_TYPE_P(zvsep) == IS_ARRAY && (tmp = zend_hash_get_current_data(Z_ARRVAL_P(zvsep)))) {
                vsep = zval_get_string(tmp);
        } else {
@@ -1192,7 +1193,7 @@ PHP_METHOD(HttpParams, offsetExists)
                return;
        }
 
-       zparams = zend_read_property(php_http_params_class_entry, getThis(), ZEND_STRL("params"), 0, &zparams_tmp);
+       zparams = zend_read_property(php_http_params_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("params"), 0, &zparams_tmp);
 
        if (Z_TYPE_P(zparams) == IS_ARRAY && (zparam = zend_symtable_find(Z_ARRVAL_P(zparams), name))) {
                RETVAL_BOOL(Z_TYPE_P(zparam) != IS_NULL);
@@ -1213,7 +1214,7 @@ PHP_METHOD(HttpParams, offsetGet)
                return;
        }
 
-       zparams = zend_read_property(php_http_params_class_entry, getThis(), ZEND_STRL("params"), 0, &zparams_tmp);
+       zparams = zend_read_property(php_http_params_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("params"), 0, &zparams_tmp);
 
        if (Z_TYPE_P(zparams) == IS_ARRAY && (zparam = zend_symtable_find(Z_ARRVAL_P(zparams), name))) {
                RETVAL_ZVAL(zparam, 1, 0);
@@ -1232,7 +1233,7 @@ PHP_METHOD(HttpParams, offsetUnset)
                return;
        }
 
-       zparams = zend_read_property(php_http_params_class_entry, getThis(), ZEND_STRL("params"), 0, &zparams_tmp);
+       zparams = zend_read_property(php_http_params_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("params"), 0, &zparams_tmp);
 
        if (Z_TYPE_P(zparams) == IS_ARRAY) {
                zend_symtable_del(Z_ARRVAL_P(zparams), name);
@@ -1252,7 +1253,7 @@ PHP_METHOD(HttpParams, offsetSet)
                return;
        }
 
-       zparams = zend_read_property(php_http_params_class_entry, getThis(), ZEND_STRL("params"), 0, &zparams_tmp);
+       zparams = zend_read_property(php_http_params_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("params"), 0, &zparams_tmp);
        convert_to_array(zparams);
 
        if (name->len) {
index 391bccf675f0534d36f079b2bb75b892a1434f9c..f2d73a4bf2fdb0b12e2bcb232d4d32cc579490af 100644 (file)
@@ -38,7 +38,7 @@ static inline void php_http_querystring_set(zval *instance, zval *params, int fl
        array_init(&qa);
 
        if (flags & QS_MERGE) {
-               zval old_tmp, *old = zend_read_property(php_http_querystring_class_entry, instance, ZEND_STRL("queryArray"), 0, &old_tmp);
+               zval old_tmp, *old = zend_read_property(php_http_querystring_class_entry, Z_OBJ_P(instance), ZEND_STRL("queryArray"), 0, &old_tmp);
 
                ZVAL_DEREF(old);
                if (Z_TYPE_P(old) == IS_ARRAY) {
@@ -47,13 +47,13 @@ static inline void php_http_querystring_set(zval *instance, zval *params, int fl
        }
 
        php_http_querystring_update(&qa, params, NULL);
-       zend_update_property(php_http_querystring_class_entry, instance, ZEND_STRL("queryArray"), &qa);
+       zend_update_property(php_http_querystring_class_entry, Z_OBJ_P(instance), ZEND_STRL("queryArray"), &qa);
        zval_ptr_dtor(&qa);
 }
 
 static inline void php_http_querystring_str(zval *instance, zval *return_value)
 {
-       zval qa_tmp, *qa = zend_read_property(php_http_querystring_class_entry, instance, ZEND_STRL("queryArray"), 0, &qa_tmp);
+       zval qa_tmp, *qa = zend_read_property(php_http_querystring_class_entry, Z_OBJ_P(instance), ZEND_STRL("queryArray"), 0, &qa_tmp);
 
        ZVAL_DEREF(qa);
        if (Z_TYPE_P(qa) == IS_ARRAY) {
@@ -65,7 +65,7 @@ static inline void php_http_querystring_str(zval *instance, zval *return_value)
 
 static inline void php_http_querystring_get(zval *instance, int type, char *name, uint32_t name_len, zval *defval, zend_bool del, zval *return_value)
 {
-       zval *arrval, qarray_tmp, *qarray = zend_read_property(php_http_querystring_class_entry, instance, ZEND_STRL("queryArray"), 0, &qarray_tmp);
+       zval *arrval, qarray_tmp, *qarray = zend_read_property(php_http_querystring_class_entry, Z_OBJ_P(instance), ZEND_STRL("queryArray"), 0, &qarray_tmp);
 
        ZVAL_DEREF(qarray);
        if ((Z_TYPE_P(qarray) == IS_ARRAY) && (arrval = zend_symtable_str_find(Z_ARRVAL_P(qarray), name, name_len))) {
@@ -254,7 +254,7 @@ ZEND_RESULT_CODE php_http_querystring_update(zval *qarray, zval *params, zval *o
 
                /* squeeze the hash out of the zval */
                if (Z_TYPE_P(params) == IS_OBJECT && instanceof_function(Z_OBJCE_P(params), php_http_querystring_class_entry)) {
-                       zval qa_tmp, *qa = zend_read_property(php_http_querystring_class_entry, params, ZEND_STRL("queryArray"), 0, &qa_tmp);
+                       zval qa_tmp, *qa = zend_read_property(php_http_querystring_class_entry, Z_OBJ_P(params), ZEND_STRL("queryArray"), 0, &qa_tmp);
 
                        ZVAL_DEREF(qa);
                        convert_to_array(qa);
@@ -378,13 +378,12 @@ PHP_METHOD(HttpQueryString, getGlobalInstance)
        if (Z_TYPE_P(instance) == IS_OBJECT) {
                RETVAL_ZVAL(instance, 1, 0);
        } else if ((_GET = php_http_env_get_superglobal(ZEND_STRL("_GET")))) {
-               zval tmp, *qa;
+               zval *qa;
+               zend_string *qa_str = zend_string_init(ZEND_STRL("queryArray"), 0);
 
                ZVAL_OBJ(return_value, php_http_querystring_object_new(php_http_querystring_class_entry));
-
-               ZVAL_STRING(&tmp, "queryArray");
-               qa = Z_OBJ_HT_P(return_value)->get_property_ptr_ptr(return_value, &tmp, BP_VAR_RW, NULL);
-               zval_ptr_dtor(&tmp);
+               qa = Z_OBJ_HT_P(return_value)->get_property_ptr_ptr(Z_OBJ_P(return_value), qa_str, BP_VAR_RW, NULL);
+               zend_string_release(qa_str);
 
                ZVAL_NEW_REF(_GET, _GET);
                ZVAL_COPY(qa, _GET);
@@ -404,10 +403,10 @@ PHP_METHOD(HttpQueryString, getIterator)
 
        php_http_expect(SUCCESS == zend_parse_parameters_none(), invalid_arg, return);
 
-       qa = zend_read_property(php_http_querystring_class_entry, getThis(), ZEND_STRL("queryArray"), 0, &qa_tmp);
+       qa = zend_read_property(php_http_querystring_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("queryArray"), 0, &qa_tmp);
 
        object_init_ex(return_value, spl_ce_RecursiveArrayIterator);
-       zend_call_method_with_1_params(return_value, spl_ce_RecursiveArrayIterator, NULL, "__construct", NULL, qa);
+       zend_call_method_with_1_params(Z_OBJ_P(return_value), spl_ce_RecursiveArrayIterator, NULL, "__construct", NULL, qa);
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpQueryString_toString, 0, 0, 0)
@@ -430,7 +429,7 @@ PHP_METHOD(HttpQueryString, toArray)
                return;
        }
 
-       zqa = zend_read_property(php_http_querystring_class_entry, getThis(), ZEND_STRL("queryArray"), 0, &zqa_tmp);
+       zqa = zend_read_property(php_http_querystring_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("queryArray"), 0, &zqa_tmp);
        RETURN_ZVAL(zqa, 1, 0);
 }
 
@@ -507,9 +506,9 @@ PHP_METHOD(HttpQueryString, mod)
        php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "z", &params), invalid_arg, return);
        
        zend_replace_error_handling(EH_THROW, php_http_get_exception_bad_querystring_class_entry(), &zeh);
-       ZVAL_OBJ(return_value, Z_OBJ_HT_P(instance)->clone_obj(instance));
+       ZVAL_OBJ(return_value, Z_OBJ_HT_P(instance)->clone_obj(Z_OBJ_P(instance)));
        /* make sure we do not inherit the reference to _GET */
-       SEPARATE_ZVAL(zend_read_property(Z_OBJCE_P(return_value), return_value, ZEND_STRL("queryArray"), 0, &qa_tmp));
+       SEPARATE_ZVAL(zend_read_property(Z_OBJCE_P(return_value), Z_OBJ_P(return_value), ZEND_STRL("queryArray"), 0, &qa_tmp));
        php_http_querystring_set(return_value, params, QS_MERGE);
        zend_restore_error_handling(&zeh);
 }
@@ -551,7 +550,7 @@ PHP_METHOD(HttpQueryString, xlate)
        php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &ie, &ie_len, &oe, &oe_len), invalid_arg, return);
 
        array_init(&na);
-       qa = zend_read_property(php_http_querystring_class_entry, getThis(), ZEND_STRL("queryArray"), 0, &qa_tmp);
+       qa = zend_read_property(php_http_querystring_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("queryArray"), 0, &qa_tmp);
        ZVAL_DEREF(qa);
        convert_to_array(qa);
 
@@ -607,7 +606,7 @@ PHP_METHOD(HttpQueryString, offsetGet)
                return;
        }
        
-       qa = zend_read_property(php_http_querystring_class_entry, getThis(), ZEND_STRL("queryArray"), 0, &qa_tmp);
+       qa = zend_read_property(php_http_querystring_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("queryArray"), 0, &qa_tmp);
        ZVAL_DEREF(qa);
 
        if (Z_TYPE_P(qa) == IS_ARRAY) {
@@ -654,7 +653,7 @@ PHP_METHOD(HttpQueryString, offsetExists)
                return;
        }
        
-       qa = zend_read_property(php_http_querystring_class_entry, getThis(), ZEND_STRL("queryArray"), 0, &qa_tmp);
+       qa = zend_read_property(php_http_querystring_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("queryArray"), 0, &qa_tmp);
        ZVAL_DEREF(qa);
 
        if (Z_TYPE_P(qa) == IS_ARRAY) {
index 24a13ff6df31818563e9217ee58532f70cbf11a4..21e38e248be4d2355ba5167f5ebc9ee61d1dc712 100644 (file)
@@ -535,7 +535,7 @@ HashTable *php_http_url_to_struct(const php_http_url_t *url, zval *strct)
        if (!strct || Z_TYPE_P(strct) == IS_ARRAY) { \
                zend_hash_str_update(ht, part, lenof(part), &tmp); \
        } else { \
-               zend_update_property(Z_OBJCE_P(strct), strct, part, lenof(part), &tmp); \
+               zend_update_property(Z_OBJCE_P(strct), Z_OBJ_P(strct), part, lenof(part), &tmp); \
                zval_ptr_dtor(&tmp); \
        }
 
@@ -1021,7 +1021,7 @@ static ZEND_RESULT_CODE parse_uidn_2003(struct parse_state *state, size_t prev_l
 #      endif
 
        efree(uhost_str);
-       if (error > U_ZERO_ERROR) {
+       if (rc > U_ZERO_ERROR) {
                goto error;
        }
 
@@ -1984,7 +1984,7 @@ PHP_METHOD(HttpUrl, mod)
                if ((old_purl = php_http_url_from_struct(HASH_OF(getThis())))) {
                        php_http_url_t *res_purl;
 
-                       ZVAL_OBJ(return_value, zend_objects_clone_obj(getThis()));
+                       ZVAL_OBJ(return_value, zend_objects_clone_obj(Z_OBJ_P(getThis())));
 
                        res_purl = php_http_url_mod(old_purl, new_purl, flags);
                        php_http_url_to_struct(res_purl, return_value);
index 27a68b4f32dfc2ee01bdaa480de23f6b028643ba..ac29865cca76dca99d4709b398b51a0ac6bde334 100644 (file)
@@ -1,12 +1,12 @@
 --TEST--
 client deprecated methods
 --SKIPIF--
-<?php 
+<?php
 include "skipif.inc";
 skip_client_test();
 ?>
 --FILE--
-<?php 
+<?php
 
 echo "Test\n";
 
@@ -19,7 +19,7 @@ $client->enablePipelining(false);
 --EXPECTF--
 Test
 
-Deprecated: Function http\Client::enableEvents() is deprecated in %sclient024.php on line %d
+Deprecated: Method http\Client::enableEvents() is deprecated in %sclient024.php on line %d
 
-Deprecated: Function http\Client::enablePipelining() is deprecated in %sclient024.php on line %d
+Deprecated: Method http\Client::enablePipelining() is deprecated in %sclient024.php on line %d
 ===DONE===
index aba014aaf7006f0b8758ab4eb618a85cbbbb1368..16948cc458a26719b66be8cc70712cde7f91b058 100644 (file)
@@ -3,7 +3,7 @@ crash when query string has nested array keys
 --SKIPIF--
 <?php
 include "skipif.inc";
-php_version_compare(PHP_VERSION, "7.0.0-dev") or die("skip php<7");
+version_compare(PHP_VERSION, "7.0.0-dev") or die("skip php<7");
 ?>
 --FILE--
 <?php
index a6f9ded527ed288ff6a9481da1a14f17f5ccf421..8c28952fa328b3ee2330baf7d14797d77343af34 100644 (file)
@@ -2,10 +2,10 @@
 URL barfs on punycode
 --SKIPIF--
 <?php
-include "./skipif.inc";
+include "skipif.inc";
 ?>
 --FILE--
-<?php 
+<?php
 echo "Test\n";
 echo new http\Url("http://www.xn--kln-sna.de"), "\n";
 ?>
diff --git a/tests/message006.phpt b/tests/message006.phpt
deleted file mode 100644 (file)
index 4d1a693..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
---TEST--
-message var_dump with inherited property with increased access level
---SKIPIF--
-<?php
-include "skipif.inc";
-?>
---FILE--
-<?php
-echo "Test\n";
-
-class c extends http\Message {
-       public $headers;
-} 
-
-$m = new c;
-$m->headers["foo"] = "bar";
-var_dump($m);
-
-?>
-DONE
---EXPECTF--
-Test
-object(c)#%d (9) {
-  ["headers"]=>
-  array(1) {
-    ["foo"]=>
-    string(3) "bar"
-  }
-  ["type":protected]=>
-  int(0)
-  ["body":protected]=>
-  NULL
-  ["requestMethod":protected]=>
-  string(0) ""
-  ["requestUrl":protected]=>
-  string(0) ""
-  ["responseStatus":protected]=>
-  string(0) ""
-  ["responseCode":protected]=>
-  int(0)
-  ["httpVersion":protected]=>
-  string(3) "1.1"
-  ["parentMessage":protected]=>
-  NULL
-}
-DONE
index c1f58d93269c215dba5d64e974fe52c9fa2ec744..0e557a023af33ecba1fe851b3d250b1f701ff433 100644 (file)
@@ -14,6 +14,6 @@ Done
 Test
 %a
 HTTP Support => enabled
-Extension Version => 3.%s
+Extension Version => 4.%s
 %a
 Done
diff --git a/tests/propertyproxy001.phpt b/tests/propertyproxy001.phpt
deleted file mode 100644 (file)
index 88a3543..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
---TEST--
-property proxy
---SKIPIF--
-<?php
-include "skipif.inc";
-?>
---FILE--
-<?php
-
-class m extends http\Message { 
-    function test1() { 
-        $this->headers["bykey"] = 1; 
-        var_dump($this->headers); 
-       }
-       function test2() {
-        $h = &$this->headers; 
-        $h["by1ref"] = 2; 
-        var_dump($this->headers); 
-       }
-       function test3() {
-        $x = &$this->headers["byXref"];
-
-        $h = &$this->headers["by2ref"]; 
-        $h = 1; 
-        var_dump($this->headers);
-
-        $x = 2;
-        var_dump($this->headers);
-       }
-       function test4() {
-        $this->headers["bynext"][] = 1;
-        $this->headers["bynext"][] = 2;
-        $this->headers["bynext"][] = 3;
-        var_dump($this->headers);
-    }
-} 
-
-$m=new m; 
-$m->test1(); 
-$m->test2(); 
-$m->test3(); 
-$m->test4(); 
-echo $m,"\n";
-
-?>
-DONE
---EXPECTF--
-array(1) {
-  ["bykey"]=>
-  int(1)
-}
-array(2) {
-  ["bykey"]=>
-  int(1)
-  ["by1ref"]=>
-  int(2)
-}
-array(3) {
-  ["bykey"]=>
-  int(1)
-  ["by1ref"]=>
-  int(2)
-  ["by2ref"]=>
-  int(1)
-}
-array(4) {
-  ["bykey"]=>
-  int(1)
-  ["by1ref"]=>
-  int(2)
-  ["by2ref"]=>
-  int(1)
-  ["byXref"]=>
-  int(2)
-}
-array(5) {
-  ["bykey"]=>
-  int(1)
-  ["by1ref"]=>
-  int(2)
-  ["by2ref"]=>
-  int(1)
-  ["byXref"]=>
-  int(2)
-  ["bynext"]=>
-  array(3) {
-    [0]=>
-    int(1)
-    [1]=>
-    int(2)
-    [2]=>
-    int(3)
-  }
-}
-bykey: 1
-by1ref: 2
-by2ref: 1
-byXref: 2
-bynext: 1
-bynext: 2
-bynext: 3
-
-DONE
-
diff --git a/tests/querystring001.phpt b/tests/querystring001.phpt
deleted file mode 100644 (file)
index e2e563d..0000000
+++ /dev/null
@@ -1,180 +0,0 @@
---TEST--
-query string
---SKIPIF--
-<?php
-include("skipif.inc");
-version_compare(PHP_VERSION, "7.2.0-dev", "<") or die("skip only for PHP < 7.2.0");
-?>
---GET--
-str=abc&num=-123&dec=123.123&bool=1&arr[]=1&arr[]=2&ma[l1][l2]=2&ma[l2][l3][l4]=3
---FILE--
-<?php
-echo "Test\n";
-
-printf("\nGlobal instance:\n");
-$q = http\QueryString::getGlobalInstance();
-printf("%s\n", $q);
-
-printf("\nStandard getters:\n");
-var_dump($q->getString("str"));
-var_dump($q->getInt("num"));
-var_dump($q->getFloat("dec"));
-var_dump($q->getInt("dec"));
-var_dump($q->getFloat("dec"));
-var_dump($q->getBool("bool"));
-var_dump($q->getInt("bool"));
-var_dump($q->getBool("num"));
-var_dump($q->getInt("num"));
-var_dump($q->getArray("arr"));
-var_dump($q->getArray("ma"));
-var_dump($q->getObject("arr"));
-var_dump($q->getObject("ma"));
-
-$s = $q->toString();
-
-printf("\nClone modifications do not alter global instance:\n");
-$q->mod(array("arr" => array(3 => 3)));
-printf("%s\n", $q);
-
-printf("\nClone modifications do not alter standard instance:\n");
-$q2 = new http\QueryString($s);
-$q3 = $q2->mod(array("arr" => array(3 => 3)));
-printf("%s\n%s\n", $q2, $q3);
-#var_dump($q2, $q3);
-
-printf("\nIterator:\n");
-$it = new RecursiveIteratorIterator($q2, RecursiveIteratorIterator::SELF_FIRST);
-foreach ($it as $k => $v) {
-       $i = $it->getDepth()*8;
-       @printf("%{$i}s: %s\n", $k, $v); 
-}
-
-printf("\nReplace a multi dimensional key:\n");
-printf("%s\n", $q2->mod(array("ma" => null))->set(array("ma" => array("l1" => false))));
-
-printf("\nXlate:\n");
-$qu = new http\QueryString("ü=ö");
-printf("utf8:   %s\n", $qu);
-printf("latin1: %s\n", method_exists($qu, "xlate") ? $qu->xlate("utf-8", "latin1") : "%FC=%F6");
-
-printf("\nOffsets:\n");
-var_dump($q2["ma"]);
-$q2["ma"] = array("bye");
-var_dump($q2["ma"]);
-var_dump(isset($q2["ma"]));
-unset($q2["ma"]);
-var_dump(isset($q2["ma"]));
-
-echo "Done\n";
-?>
---EXPECTF--
-Test
-
-Global instance:
-str=abc&num=-123&dec=123.123&bool=1&arr%5B0%5D=1&arr%5B1%5D=2&ma%5Bl1%5D%5Bl2%5D=2&ma%5Bl2%5D%5Bl3%5D%5Bl4%5D=3
-
-Standard getters:
-string(3) "abc"
-int(-123)
-float(123.123)
-int(123)
-float(123.123)
-bool(true)
-int(1)
-bool(true)
-int(-123)
-array(2) {
-  [0]=>
-  string(1) "1"
-  [1]=>
-  string(1) "2"
-}
-array(2) {
-  ["l1"]=>
-  array(1) {
-    ["l2"]=>
-    string(1) "2"
-  }
-  ["l2"]=>
-  array(1) {
-    ["l3"]=>
-    array(1) {
-      ["l4"]=>
-      string(1) "3"
-    }
-  }
-}
-object(stdClass)#%d (2) {
-  [0]=>
-  string(1) "1"
-  [1]=>
-  string(1) "2"
-}
-object(stdClass)#%d (2) {
-  ["l1"]=>
-  array(1) {
-    ["l2"]=>
-    string(1) "2"
-  }
-  ["l2"]=>
-  array(1) {
-    ["l3"]=>
-    array(1) {
-      ["l4"]=>
-      string(1) "3"
-    }
-  }
-}
-
-Clone modifications do not alter global instance:
-str=abc&num=-123&dec=123.123&bool=1&arr%5B0%5D=1&arr%5B1%5D=2&ma%5Bl1%5D%5Bl2%5D=2&ma%5Bl2%5D%5Bl3%5D%5Bl4%5D=3
-
-Clone modifications do not alter standard instance:
-str=abc&num=-123&dec=123.123&bool=1&arr%5B0%5D=1&arr%5B1%5D=2&ma%5Bl1%5D%5Bl2%5D=2&ma%5Bl2%5D%5Bl3%5D%5Bl4%5D=3
-str=abc&num=-123&dec=123.123&bool=1&arr%5B0%5D=1&arr%5B1%5D=2&arr%5B3%5D=3&ma%5Bl1%5D%5Bl2%5D=2&ma%5Bl2%5D%5Bl3%5D%5Bl4%5D=3
-
-Iterator:
-str: abc
-num: -123
-dec: 123.123
-bool: 1
-arr: Array
-       0: 1
-       1: 2
-ma: Array
-      l1: Array
-              l2: 2
-      l2: Array
-              l3: Array
-                      l4: 3
-
-Replace a multi dimensional key:
-str=abc&num=-123&dec=123.123&bool=1&arr%5B0%5D=1&arr%5B1%5D=2&ma%5Bl1%5D=
-
-Xlate:
-utf8:   %C3%BC=%C3%B6
-latin1: %FC=%F6
-
-Offsets:
-array(2) {
-  ["l1"]=>
-  array(1) {
-    ["l2"]=>
-    string(1) "2"
-  }
-  ["l2"]=>
-  array(1) {
-    ["l3"]=>
-    array(1) {
-      ["l4"]=>
-      string(1) "3"
-    }
-  }
-}
-array(1) {
-  [0]=>
-  string(3) "bye"
-}
-bool(true)
-bool(false)
-Done
index 85dbac2902d2c2ae7915b9fe9dcc18d4d6d053c5..51272fbe575b16705e7cb24564e9154e494d6331 100644 (file)
@@ -1,13 +1,17 @@
 <?php
 _ext("http");
 
-function _ext($ext) { 
+function _ext($ext) {
        if (!extension_loaded($ext)) {
                die("skip $ext extension needed\n");
        }
 }
 
 function utf8locale() {
+       $locale = setlocale(LC_CTYPE, null);
+       if (stristr($locale, "utf") && substr($locale, -1) === "8") {
+               return true;
+       }
        if (stristr(setlocale(LC_CTYPE, "C.UTF-8"), "utf")) {
                return true;
        }
@@ -37,8 +41,8 @@ function skip_client_test($message = "skip need a client driver\n") {
 }
 
 function skip_curl_test($version) {
-       if (!version_compare(http\Client\Curl\Versions\CURL, $version, "<=")) {
-               die("need at least libcurl version $version\n");
+       if (!version_compare(http\Client\Curl\Versions\CURL, $version, ">=")) {
+               die("skip need at least libcurl version $version\n");
        }
 }
 
index 36d6983eed9e09bb4fc65f1331b42d5358c65621..4eab3b749a053169fd22bc4dac68fc40002fa5ba 100644 (file)
@@ -11,7 +11,8 @@ if (!defined("http\\Url::PARSE_MBLOC") or
 --FILE--
 <?php
 echo "Test\n";
-setlocale(LC_CTYPE, "C.UTF-8");
+include "skipif.inc";
+utf8locale();
 
 $urls = array(
        "s\xc3\xa7heme:",
index e047ada501481cd9bd3acefc53d7bfe768833107..1ef4c593feb5ab1e7704e6de687ab6c8c7138f94 100644 (file)
@@ -12,7 +12,8 @@ if (!defined("http\\Url::PARSE_MBLOC") or
 --FILE--
 <?php
 echo "Test\n";
-setlocale(LC_CTYPE, "C.UTF-8");
+include "skipif.inc";
+utf8locale();
 
 $urls = array(
        "s\xc3\xa7heme:",
index f5382085e17a481ac626c3fa0a50a75bdeb9058e..e2e36db777065f472ee6dc734f1bb8758cc82328 100644 (file)
@@ -12,7 +12,8 @@ if (!defined("http\\Url::PARSE_MBLOC") or
 --FILE--
 <?php
 echo "Test\n";
-setlocale(LC_CTYPE, "C.UTF-8");
+include "skipif.inc";
+utf8locale();
 
 $urls = array(
        "http://mike:paßwort@𐌀𐌁𐌂.it/for/€/?by=¢#ø"
index d80cd1313556649e049ca4ba34f9aa3e5548394c..4c7e70489ad0e2b7a89228af55396f673a6a63d2 100644 (file)
@@ -13,7 +13,8 @@ if (!defined("http\\Url::PARSE_MBLOC") or
 --FILE--
 <?php
 echo "Test\n";
-setlocale(LC_CTYPE, "C.UTF-8");
+include "skipif.inc";
+utf8locale();
 
 $urls = array(
        "http://mike:paßwort@𐌀𐌁𐌂.it/for/€/?by=¢#ø"