better PHP-5.3 compatibility
authorMichael Wallner <mike@php.net>
Thu, 8 Nov 2012 13:46:20 +0000 (13:46 +0000)
committerMichael Wallner <mike@php.net>
Thu, 8 Nov 2012 13:46:20 +0000 (13:46 +0000)
28 files changed:
php_http_client.c
php_http_client_datashare.c
php_http_client_pool.c
php_http_cookie.c
php_http_curl_client.c
php_http_curl_client_datashare.c
php_http_curl_client_pool.c
php_http_encoding.c
php_http_env.c
php_http_env_response.c
php_http_message.c
php_http_message_body.c
php_http_misc.h
php_http_object.c
php_http_property_proxy.c
php_http_querystring.c
phpunit.php [new file with mode: 0644]
phpunit/ObjectTest.php
phpunit/RequestTest.php
phpunit/UrlTest.php
reflection2php.php
tests/etag001.phpt
tests/factory.phpt
tests/message004.phpt
tests/persistenthandles001.phpt
tests/phpunit.phpt
tests/response003.phpt
tests/serialize001.phpt

index 8f51a03a9c535c9ce91ca9deed9691a4b7ebaa40..79a0ef8d699322b88392af6069e1884ad4dd9706 100644 (file)
@@ -296,11 +296,8 @@ zend_object_value php_http_client_object_new_ex(zend_class_entry *ce, php_http_c
 
        o = ecalloc(1, sizeof(*o));
        zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
-#if PHP_VERSION_ID < 50339
-       zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
-#else
        object_properties_init((zend_object *) o, ce);
-#endif
+       
        ov.handle = zend_objects_store_put(o, NULL, php_http_client_object_free, NULL TSRMLS_CC);
        ov.handlers = &php_http_client_object_handlers;
 
index 5f7a90a26ab13406fd511b0256b85587fabec4d5..387df53656ddc2875f0e065b3f56adabdcaf942e 100644 (file)
@@ -147,11 +147,7 @@ PHP_HTTP_BEGIN_ARGS(detach, 1)
        PHP_HTTP_ARG_OBJ(http\\Client, client, 0)
 PHP_HTTP_END_ARGS;
 
-static void php_http_client_datashare_object_write_prop(zval *object, zval *member, zval *value
-#if PHP_VERSION_ID >= 50400
-, const zend_literal *literal_key 
-#endif
-TSRMLS_DC);
+static void php_http_client_datashare_object_write_prop(zval *object, zval *member, zval *value PHP_HTTP_ZEND_LITERAL_DC TSRMLS_DC);
 
 static zend_class_entry *php_http_client_datashare_class_entry;
 
@@ -205,11 +201,7 @@ zend_object_value php_http_client_datashare_object_new_ex(zend_class_entry *ce,
 
        o = ecalloc(1, sizeof(*o));
        zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
-#if PHP_VERSION_ID < 50339
-       zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
-#else
        object_properties_init((zend_object *) o, ce);
-#endif
 
        ov.handle = zend_objects_store_put(o, NULL, php_http_client_datashare_object_free, NULL TSRMLS_CC);
        ov.handlers = &php_http_client_datashare_object_handlers;
@@ -234,11 +226,7 @@ void php_http_client_datashare_object_free(void *object TSRMLS_DC)
        efree(o);
 }
 
-static void php_http_client_datashare_object_write_prop(zval *object, zval *member, zval *value
-#if PHP_VERSION_ID >= 50400
-, const zend_literal *literal_key 
-#endif
-TSRMLS_DC)
+static void php_http_client_datashare_object_write_prop(zval *object, zval *member, zval *value PHP_HTTP_ZEND_LITERAL_DC TSRMLS_DC)
 {
        zend_property_info *pi;
 
@@ -262,18 +250,10 @@ TSRMLS_DC)
                }
        }
 
-       zend_get_std_object_handlers()->write_property(object, member, value
-#if PHP_VERSION_ID >= 50400
-       , literal_key 
-#endif
-       TSRMLS_CC);
+       zend_get_std_object_handlers()->write_property(object, member, value PHP_HTTP_ZEND_LITERAL_CC TSRMLS_CC);
 }
 
-static zval **php_http_client_datashare_object_get_prop_ptr(zval *object, zval *member
-#if PHP_VERSION_ID >= 50400
-, const zend_literal *literal_key
-#endif
-TSRMLS_DC)
+static zval **php_http_client_datashare_object_get_prop_ptr(zval *object, zval *member PHP_HTTP_ZEND_LITERAL_DC TSRMLS_DC)
 {
        zend_property_info *pi;
 
@@ -281,11 +261,7 @@ TSRMLS_DC)
                return &php_http_property_proxy_init(NULL, object, member, NULL TSRMLS_CC)->myself;
        }
 
-       return zend_get_std_object_handlers()->get_property_ptr_ptr(object, member
-#if PHP_VERSION_ID >= 50400
-       , literal_key
-#endif
-       TSRMLS_CC);
+       return zend_get_std_object_handlers()->get_property_ptr_ptr(object, member PHP_HTTP_ZEND_LITERAL_CC TSRMLS_CC);
 }
 
 
index 93e5e0a1c5b52372c9f111297e2973a1e3e06709..04a730600783de198624cb4209874b7f08366fff 100644 (file)
@@ -321,11 +321,7 @@ zend_object_value php_http_client_pool_object_new_ex(zend_class_entry *ce, php_h
 
        o = ecalloc(1, sizeof(php_http_client_pool_object_t));
        zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
-#if PHP_VERSION_ID < 50339
-       zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
-#else
        object_properties_init((zend_object *) o, ce);
-#endif
 
        if (!(o->pool = p)) {
                o->pool = php_http_client_pool_init(NULL, &php_http_client_pool_user_ops, NULL, NULL TSRMLS_CC);
index 5b78abbe0dd161d9595839f14d88bbff065b47f8..6908d386247e4b09de79af5b3e4618beb8887ffe 100644 (file)
@@ -463,11 +463,7 @@ zend_object_value php_http_cookie_object_new_ex(zend_class_entry *ce, php_http_c
 
        o = ecalloc(sizeof(*o), 1);
        zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
-#if PHP_VERSION_ID < 50339
-       zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
-#else
        object_properties_init((zend_object *) o, ce);
-#endif
 
        if (list) {
                o->list = list;
index 01678d8c2d0a66d1f981f5ec0b36c47633226197..32dbb7edc27f276ca6631927e7819d3bf9b1d524 100644 (file)
@@ -1307,11 +1307,7 @@ zend_object_value php_http_curl_client_object_new_ex(zend_class_entry *ce, php_h
 
        o = ecalloc(1, sizeof(php_http_client_object_t));
        zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
-#if PHP_VERSION_ID < 50339
-       zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
-#else
        object_properties_init((zend_object *) o, ce);
-#endif
 
        if (!(o->client = r)) {
                o->client = php_http_client_init(NULL, &php_http_curl_client_ops, NULL, NULL TSRMLS_CC);
index 1c9cf4d7178964647b94ee7dc0d3b426e889257a..3668512bccf93d2f6777e4451adc89fb1fffbd73 100644 (file)
@@ -191,11 +191,7 @@ zend_object_value php_http_curl_client_datashare_object_new_ex(zend_class_entry
 
        o = ecalloc(1, sizeof(*o));
        zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
-#if PHP_VERSION_ID < 50339
-       zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
-#else
        object_properties_init((zend_object *) o, ce);
-#endif
 
        if (share) {
                o->share = share;
index ddac5c18552f015b13047694fb009dbb7c9bb7a3..6ae1da658ae99886433b3fb347fa106ee1fd749a 100644 (file)
@@ -527,11 +527,7 @@ zend_object_value php_http_curl_client_pool_object_new_ex(zend_class_entry *ce,
 
        o = ecalloc(1, sizeof(php_http_client_pool_object_t));
        zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
-#if PHP_VERSION_ID < 50339
-       zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
-#else
        object_properties_init((zend_object *) o, ce);
-#endif
 
        if (!(o->pool = p)) {
                o->pool = php_http_client_pool_init(NULL, &php_http_curl_client_pool_ops, NULL, NULL TSRMLS_CC);
index c84c30981277d7f478a83e2330da97a88dfb555b..4a71c80074d24f1ea902a641df09810c13653312 100644 (file)
@@ -959,11 +959,7 @@ zend_object_value php_http_encoding_stream_object_new_ex(zend_class_entry *ce, p
 
        o = ecalloc(1, sizeof(*o));
        zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
-#if PHP_VERSION_ID < 50339
-       zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
-#else
        object_properties_init((zend_object *) o, ce);
-#endif
 
        if (ptr) {
                *ptr = o;
index 3ca996f43fabff7a34bdfcc36035955c47c37b2b..f2d4a38dec43adad76ee3e9ddcfdf21349b05dd2 100644 (file)
@@ -4,7 +4,7 @@
     +--------------------------------------------------------------------+
     | Redistribution and use in source and binary forms, with or without |
     | modification, are permitted provided that the conditions mentioned |
-    | in the accomp395anying LICENSE file are met.                          |
+    | in the accompanying LICENSE file are met.                          |
     +--------------------------------------------------------------------+
     | Copyright (c) 2004-2011, Michael Wallner <mike@php.net>            |
     +--------------------------------------------------------------------+
@@ -987,7 +987,7 @@ PHP_METHOD(HttpEnv, cleanPersistentHandles)
 static SAPI_POST_HANDLER_FUNC(php_http_json_post_handler)
 {
        if (SG(request_info).raw_post_data) {
-               php_json_decode_ex(arg, SG(request_info).raw_post_data, SG(request_info).raw_post_data_length, PHP_JSON_OBJECT_AS_ARRAY, PG(max_input_nesting_level) TSRMLS_CC);
+               php_json_decode(arg, SG(request_info).raw_post_data, SG(request_info).raw_post_data_length, 1, PG(max_input_nesting_level) TSRMLS_CC);
        }
 }
 
index c3cf80b891a4bd7a6fd37144e7f04863ad0192b1..d88fb72841386e6eec7372ace3c1783f62fd3ea6 100644 (file)
@@ -189,6 +189,9 @@ static size_t output(void *context, char *buf, size_t len TSRMLS_DC)
                if (!(php_output_get_status(TSRMLS_C) & PHP_OUTPUT_IMPLICITFLUSH)) {
                        sapi_flush(TSRMLS_C);
                }
+#else
+               php_end_ob_buffer(1, 1 TSRMLS_CC);
+               sapi_flush(TSRMLS_C);
 #endif
                php_http_sleep(r->throttle.delay);
        }
index a93d9f5632c5f0c2f97053b60a271d94424717e3..e4b4660d7d3de54259c4d6600f24f66b9d3cfc15 100644 (file)
@@ -89,7 +89,7 @@ PHP_HTTP_API php_http_message_t *php_http_message_init_env(php_http_message_t *m
                        }
                        
                        php_http_env_get_response_headers(&message->hdrs TSRMLS_CC);
-
+#if PHP_VERSION_ID >= 50400
                        if (php_output_get_level(TSRMLS_C)) {
                                if (php_output_get_status(TSRMLS_C) & PHP_OUTPUT_SENT) {
                                        php_http_error(HE_WARNING, PHP_HTTP_E_RUNTIME, "Could not fetch response body, output has already been sent at %s:%d", php_output_get_start_filename(TSRMLS_C), php_output_get_start_lineno(TSRMLS_C));
@@ -102,6 +102,7 @@ PHP_HTTP_API php_http_message_t *php_http_message_init_env(php_http_message_t *m
                                        zval_dtor(&tval);
                                }
                        }
+#endif
                        break;
                        
                default:
@@ -671,9 +672,9 @@ PHP_HTTP_BEGIN_ARGS(isMultipart, 0)
 PHP_HTTP_END_ARGS;
 PHP_HTTP_EMPTY_ARGS(splitMultipartBody);
 
-static zval *php_http_message_object_read_prop(zval *object, zval *member, int type, const zend_literal *literal_key TSRMLS_DC);
-static void php_http_message_object_write_prop(zval *object, zval *member, zval *value, const zend_literal *literal_key TSRMLS_DC);
-static zval **php_http_message_object_get_prop_ptr(zval *object, zval *member, const zend_literal *literal_key TSRMLS_DC);
+static zval *php_http_message_object_read_prop(zval *object, zval *member, int type PHP_HTTP_ZEND_LITERAL_DC TSRMLS_DC);
+static void php_http_message_object_write_prop(zval *object, zval *member, zval *value PHP_HTTP_ZEND_LITERAL_DC TSRMLS_DC);
+static zval **php_http_message_object_get_prop_ptr(zval *object, zval *member PHP_HTTP_ZEND_LITERAL_DC TSRMLS_DC);
 static HashTable *php_http_message_object_get_props(zval *object TSRMLS_DC);
 
 static zend_class_entry *php_http_message_class_entry;
@@ -1140,7 +1141,7 @@ void php_http_message_object_free(void *object TSRMLS_DC)
 }
 
 
-static zval **php_http_message_object_get_prop_ptr(zval *object, zval *member, const zend_literal *literal_key TSRMLS_DC)
+static zval **php_http_message_object_get_prop_ptr(zval *object, zval *member PHP_HTTP_ZEND_LITERAL_DC TSRMLS_DC)
 {
        php_http_message_object_prophandler_t *handler;
        zval *copy = php_http_ztyp(IS_STRING, member);
@@ -1151,10 +1152,10 @@ static zval **php_http_message_object_get_prop_ptr(zval *object, zval *member, c
        }
        zval_ptr_dtor(&copy);
 
-       return zend_get_std_object_handlers()->get_property_ptr_ptr(object, member, literal_key TSRMLS_CC);
+       return zend_get_std_object_handlers()->get_property_ptr_ptr(object, member PHP_HTTP_ZEND_LITERAL_CC TSRMLS_CC);
 }
 
-static zval *php_http_message_object_read_prop(zval *object, zval *member, int type, const zend_literal *literal_key TSRMLS_DC)
+static zval *php_http_message_object_read_prop(zval *object, zval *member, int type PHP_HTTP_ZEND_LITERAL_DC TSRMLS_DC)
 {
        php_http_message_object_t *obj = zend_object_store_get_object(object TSRMLS_CC);
        php_http_message_object_prophandler_t *handler;
@@ -1172,7 +1173,7 @@ static zval *php_http_message_object_read_prop(zval *object, zval *member, int t
                        return_value = NULL;
                }
        } else {
-               return_value = zend_get_std_object_handlers()->read_property(object, member, type, literal_key TSRMLS_CC);
+               return_value = zend_get_std_object_handlers()->read_property(object, member, type PHP_HTTP_ZEND_LITERAL_CC TSRMLS_CC);
        }
 
        zval_ptr_dtor(&copy);
@@ -1180,7 +1181,7 @@ static zval *php_http_message_object_read_prop(zval *object, zval *member, int t
        return return_value;
 }
 
-static void php_http_message_object_write_prop(zval *object, zval *member, zval *value, const zend_literal *literal_key TSRMLS_DC)
+static void php_http_message_object_write_prop(zval *object, zval *member, zval *value PHP_HTTP_ZEND_LITERAL_DC TSRMLS_DC)
 {
        php_http_message_object_t *obj = zend_object_store_get_object(object TSRMLS_CC);
        php_http_message_object_prophandler_t *handler;
@@ -1189,7 +1190,7 @@ static void php_http_message_object_write_prop(zval *object, zval *member, zval
        if (SUCCESS == php_http_message_object_get_prophandler(Z_STRVAL_P(copy), Z_STRLEN_P(copy), &handler)) {
                handler->write(obj, value TSRMLS_CC);
        } else {
-               zend_get_std_object_handlers()->write_property(object, member, value, literal_key TSRMLS_CC);
+               zend_get_std_object_handlers()->write_property(object, member, value PHP_HTTP_ZEND_LITERAL_CC TSRMLS_CC);
        }
 
        zval_ptr_dtor(&copy);
index 40a168876873d03cd312715b0d8c93e7a4b9755c..cf22e7035d9f89a1d050f1d487202f5492351823 100644 (file)
@@ -617,11 +617,7 @@ zend_object_value php_http_message_body_object_new_ex(zend_class_entry *ce, php_
 
        o = ecalloc(1, sizeof(php_http_message_body_object_t));
        zend_object_std_init((zend_object *) o, php_http_message_body_class_entry TSRMLS_CC);
-#if PHP_VERSION_ID < 50339
-       zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
-#else
        object_properties_init((zend_object *) o, ce);
-#endif
 
        if (ptr) {
                *ptr = o;
index 972ba92855c3e99db3b2041c1ea27513267aeeed..54e1ac5d8d48e39be9ae28aab581b71eef7da805 100644 (file)
@@ -151,6 +151,21 @@ static inline const char *php_http_locate_bin_eol(const char *bin, size_t len, i
 
 /* ZEND */
 
+#if PHP_VERSION_ID < 50400
+#      define object_properties_init(o, ce) zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*))
+#      define PHP_HTTP_ZEND_LITERAL_DC 
+#      define PHP_HTTP_ZEND_LITERAL_CC
+#      define PHP_HTTP_ZEND_LITERAL_CCN
+#      define ZVAL_COPY_VALUE(zv, arr) do { \
+               (zv)->value = (arr)->value; \
+               Z_TYPE_P(zv) = Z_TYPE_P(arr); \
+       } while (0)
+#else
+#      define PHP_HTTP_ZEND_LITERAL_DC , const zend_literal *literal_key
+#      define PHP_HTTP_ZEND_LITERAL_CC , (literal_key)
+#      define PHP_HTTP_ZEND_LITERAL_CCN , NULL
+#endif
+
 #define INIT_PZVAL_ARRAY(zv, ht) \
        { \
                INIT_PZVAL((zv)); \
index f85960f6acbb3cc3979f2e4a121313d1ac763642..c278e6bc08b9b75c700b198bf386173154ffcf49 100644 (file)
@@ -98,11 +98,7 @@ zend_object_value php_http_object_new_ex(zend_class_entry *ce, void *nothing, ph
 
        o = ecalloc(1, sizeof(php_http_object_t));
        zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
-#if PHP_VERSION_ID < 50339
-       zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
-#else
        object_properties_init((zend_object *) o, ce);
-#endif
 
        if (ptr) {
                *ptr = o;
index 781c0c0ccc5c60e67ed8d579bc93d7406b46efbd..f4d352300cee50da02405c5ece530d0f3f568600 100644 (file)
@@ -91,11 +91,7 @@ zend_object_value php_http_property_proxy_object_new_ex(zend_class_entry *ce, ph
 
        o = ecalloc(1, sizeof(*o));
        zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
-#if PHP_VERSION_ID < 50339
-       zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
-#else
        object_properties_init((zend_object *) o, ce);
-#endif
 
        if (ptr) {
                *ptr = o;
index e14504cd5eb0b163b8fe1fbed10fb849b8b431f5..2c6ca287bd3eb2758ac7c8fe9974a626bc4f989d 100644 (file)
@@ -468,7 +468,7 @@ PHP_METHOD(HttpQueryString, getGlobalInstance)
        with_error_handling(EH_THROW, php_http_exception_get_class_entry()) {
                if (SUCCESS == zend_parse_parameters_none()) {
                        with_error_handling(EH_THROW, php_http_exception_get_class_entry()) {
-                               zval *instance = *zend_std_get_static_property(php_http_querystring_class_entry, ZEND_STRL("instance"), 0, NULL TSRMLS_CC);
+                               zval *instance = *zend_std_get_static_property(php_http_querystring_class_entry, ZEND_STRL("instance"), 0 PHP_HTTP_ZEND_LITERAL_CCN TSRMLS_CC);
 
                                if (Z_TYPE_P(instance) != IS_OBJECT) {
                                        zval **_GET = NULL;
diff --git a/phpunit.php b/phpunit.php
new file mode 100644 (file)
index 0000000..8a61937
--- /dev/null
@@ -0,0 +1,4 @@
+<?php
+require_once "PHPUnit/Autoload.php";
+$c = new PHPUnit_TextUI_Command;
+$c->run(array_merge($argv, array(__DIR__."/phpunit/")));
index bce3a526d80557eeb25610f5ec63706a51629e82..968f3f88177dde052f74229a83b4a7ef14d7a633 100644 (file)
@@ -19,19 +19,22 @@ class ObjectTest extends PHPUnit_Framework_TestCase {
 
     function testSuppress() {
         http\Object::setDefaultErrorHandling(http\Object::EH_SUPPRESS);
-        (new eh)->triggerError(E_USER_WARNING, http\Exception::E_UNKNOWN, "suppress");
+        $o = new eh;
+               $o->triggerError(E_USER_WARNING, http\Exception::E_UNKNOWN, "suppress");
     }
 
     function testException() {
         http\Object::setDefaultErrorHandling(http\Object::EH_THROW);
         $this->setExpectedException("http\\Exception");
-        (new eh)->triggerError(E_USER_WARNING, http\Exception::E_UNKNOWN, "exception");
+        $o = new eh;
+               $o->triggerError(E_USER_WARNING, http\Exception::E_UNKNOWN, "exception");
     }
 
     function testNormalError() {
         http\Object::setDefaultErrorHandling(http\Object::EH_NORMAL);
         $this->setExpectedException("PHPUnit_Framework_Error_Warning");
-        (new eh)->triggerError(E_USER_WARNING, http\Exception::E_UNKNOWN, "warning");
+        $o = new eh;
+               $o->triggerError(E_USER_WARNING, http\Exception::E_UNKNOWN, "warning");
     }
 
     function testSuppress2() {
index a327f6dff2440eb49a26a118dadeb6a9ae649e5d..136b29f7433ecfcfb6809223916a027beb75d4d3 100644 (file)
@@ -28,7 +28,8 @@ class RequestTest extends PHPUnit_Framework_TestCase
     protected $r;
 
     function setUp() {
-        $this->r = (new http\Client\Factory)->createClient();
+               $f = new http\Client\Factory;
+        $this->r = $f->createClient();
         $this->r->setOptions(
             array(
                 "connecttimeout"    => 30,
@@ -55,19 +56,20 @@ class RequestTest extends PHPUnit_Framework_TestCase
     }
 
     function testObserver() {
+               $test = $this;
         $this->r->attach($o1 = new ProgressObserver1);
         $this->r->attach($o2 = new ProgressObserver2);
         $this->r->attach(
             $o3 = new CallbackObserver(
-                function ($r) {
+                function ($r) use ($test) {
                     $p = (array) $r->getProgress();
-                    $this->assertArrayHasKey("started", $p);
-                    $this->assertArrayHasKey("finished", $p);
-                    $this->assertArrayHasKey("dlnow", $p);
-                    $this->assertArrayHasKey("ulnow", $p);
-                    $this->assertArrayHasKey("dltotal", $p);
-                    $this->assertArrayHasKey("ultotal", $p);
-                    $this->assertArrayHasKey("info", $p);
+                    $test->assertArrayHasKey("started", $p);
+                    $test->assertArrayHasKey("finished", $p);
+                    $test->assertArrayHasKey("dlnow", $p);
+                    $test->assertArrayHasKey("ulnow", $p);
+                    $test->assertArrayHasKey("dltotal", $p);
+                    $test->assertArrayHasKey("ultotal", $p);
+                    $test->assertArrayHasKey("info", $p);
                 }
             )
         );
index 50fa2ff2f0605ae7a9f9a9b6d907804dbdf0c540..dcf3b4fdd2533db26be145c3c874fdd1b9b2ab15 100644 (file)
@@ -43,6 +43,7 @@ class UrlTest extends PHPUnit_Framework_TestCase {
 
     function testArrays() {
         $url = new http\Url($this->url);
-        $this->assertEquals($url->toArray(), (new http\Url($url->toArray()))->toArray());
+               $url2 = new http\Url($url->toArray());
+        $this->assertEquals($url->toArray(), $url2->toArray());
     }
 }
index e319bd4074cfbd3fb18bc73f026e7044f99d0ca3..aa238ed1980fc144a3a555bcbf28f8e96d700d36 100755 (executable)
@@ -31,6 +31,8 @@ function c($n, $c) {
 if (!strlen($ext = $argv[1]))
        die(sprintf("Usage: %s <ext>\n", $argv[0]));
 
+printf("<?php\n\n");
+
 $ext = new ReflectionExtension($ext);
 foreach ($ext->getConstants() as $constant => $value) {
     printf("const %s = %s;\n", $constant, $value);
@@ -111,7 +113,12 @@ foreach ($classes as $class) {
                 }
                                $ps[] = $p1;
                        }
-                       printf("%s) {\n\t\t}\n", implode(", ", $ps));
+                       printf("%s)", implode(", ", $ps));
+                       if ($m->isAbstract()) {
+                               printf(";\n\n");
+                       } else {
+                               printf(" {\n\t\t}\n\n");
+                       }
                }
        }
 
index 77659d3becbaa581d3bdc923aae19a751b18fe37..4a866814a7a5697ede701700f9aa6a1f39745781 100644 (file)
@@ -1,7 +1,11 @@
 --TEST--
 etags with hash
 --SKIPIF--
-<?php include "skipif.inc"; _ext("hash"); ?>
+<?php 
+include "skipif.inc"; 
+_ext("hash"); 
+version_compare(PHP_VERSION, "5.4.0", ">=") or die("skip PHP>=5.4 required");
+?>
 --FILE--
 <?php
 $body = new http\Message\Body;
index 6a629768102506962d894628880f0862f436d554..64969132757aa4be3b54f3aaddaa5e6b2cd0d76f 100644 (file)
@@ -39,7 +39,8 @@ var_dump(
 
 foreach (array("Client", "Pool", "DataShare") as $type) {
        try {
-               var_dump((new http\Client\Factory(array("driver" => "nonexistant")))->{"create$type"}());
+               $f = new http\Client\Factory(array("driver" => "nonexistant"));
+               var_dump($f->{"create$type"}());
        } catch (Exception $e) {
                echo $e->getMessage(), "\n";
        }
index de2e4e415e10d8fe1990303da9c757273480e378..914a8dab0a29c28161c1899bfc4366f9359a6380 100644 (file)
@@ -8,12 +8,16 @@ include "skip.inc";
 
 use http\Message as HttpMessage;
 
+function newHttpMessage($s) {
+       return new http\Message($s);
+}
+
 $s = "GET /first HTTP/1.1\nHTTP/1.1 200 Ok-first\nGET /second HTTP/1.1\nHTTP/1.1 200 Ok-second\nGET /third HTTP/1.1\nHTTP/1.1 200 Ok-third\n";
-echo (new HttpMessage($s))->toString(true);
+echo newHttpMessage($s)->toString(true);
 echo "===\n";
-echo (new HttpMessage($s))->reverse()->toString(true);
+echo newHttpMessage($s)->reverse()->toString(true);
 
-$m = new HttpMessage($s);
+$m = newHttpMessage($s);
 $r = $m->reverse();
 unset($m);
 var_dump($r->count());
index 01f5069bea86b75e511a9aaa3f09d3e7838b89f5..18bce8a6b9b87bfc3400eafa75bd10b36502df09 100644 (file)
@@ -4,12 +4,12 @@ persistent handles
 <?php include "skipif.inc"; ?>
 --FILE--
 <?php
-(new http\Client\Factory(array("persistentHandleId" => "foo")))
-    ->createClient()->setRequest(new http\Client\Request("GET", "http://dev.iworks.at"))
+$f = new http\Client\Factory(array("persistentHandleId" => "foo"));
+$r = $f->createClient()->setRequest(new http\Client\Request("GET", "http://dev.iworks.at"))
     ->setOptions(array("connecttimeout"=> 90, "timeout" =>300))
-    ->send(null); 
-$r = (new http\Client\Factory(array("persistentHandleId" => "bar")))
-    ->createClient()->setRequest(new http\Client\Request("GET", "http://dev.iworks.at"))
+    ->send(null);
+$f = new http\Client\Factory(array("persistentHandleId" => "bar"));
+$r = $f->createClient()->setRequest(new http\Client\Request("GET", "http://dev.iworks.at"))
     ->setOptions(array("connecttimeout"=> 90, "timeout" =>300));
     
 var_dump(http\Env::statPersistentHandles()); 
index 6320f61ba1811b90e110ea7dece31dcfdccfd01c..9c106f00e67b65b0e94d9a17d64489cb27bd5532 100644 (file)
@@ -2,12 +2,13 @@
 unit tests
 --SKIPIF--
 <?php
-@include_once "PHPUnit/Autoload.php" or die("skip need PHPUnit in include_path");
+if (!@include_once "PHPUnit/Autoload.php") die("skip need PHPUnit in include_path");
 ?>
 --FILE--
 <?php
 require_once "PHPUnit/Autoload.php";
-(new PHPUnit_TextUI_Command)->run([null, __DIR__."/../phpunit"]);
+$c = new PHPUnit_TextUI_Command;
+$c->run(array("--process-isolation", __DIR__."/../phpunit/"));
 ?>
 --EXPECTF--
 PHPUnit %s by Sebastian Bergmann.
index f83df3b8656f1a3d28579ec6d865d66c9586913b..8331e0f8c721cb1c2759c17c8ec4961cdf2a3358 100644 (file)
@@ -12,7 +12,7 @@ a=b
 $r = new http\Env\Response;
 $r->setContentType("text/plain");
 $r->setContentDisposition(
-    ["attachment" => ["filename" => basename(__FILE__)]]
+    array("attachment" => array("filename" => basename(__FILE__)))
 );
 $r->setBody(new http\Message\Body(fopen(__FILE__, "rb")));
 $r->send();
index 2e06afe4f7c3bde0109b000172d8bef2f08ca581..b37b230ba901327c1f5a2a4d3c9f4b5848112c98 100644 (file)
@@ -23,7 +23,7 @@ foreach ($ext->getClasses() as $class) {
                $serialized = serialize($instance);
                $unserialized = unserialize($serialized);
                
-               foreach (["toString", "toArray"] as $m) {
+               foreach (array("toString", "toArray") as $m) {
                        if ($class->hasMethod($m)) {
                                #printf("%s#%s\n", $class->getName(), $m);
                                $unserialized->$m();
@@ -31,7 +31,9 @@ foreach ($ext->getClasses() as $class) {
                }
                if ($class->hasMethod("attach") && !$class->implementsInterface("\\SplSubject")) {
                        #printf("%s#%s\n", $class->getName(), "attach");
-                       $unserialized->attach((new http\Curl\Client)->setRequest(new http\Client\Request("GET", "http://localhost")));
+                       $c = new http\Curl\Client;
+                       $c->setRequest(new http\Client\Request("GET", "http://localhost"));
+                       $unserialized->attach($c);
                }
        }
 }