From 79e8189c0ec666791bf6cf12c33af591fa3bba8f Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Wed, 26 Aug 2020 11:01:52 +0200 Subject: [PATCH 1/3] fix "static bu not defined" build warnings --- http_message.c | 30 +++++++++++++++--------------- php_http_message.h | 3 --- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/http_message.c b/http_message.c index 13dca6f..76ec02c 100644 --- a/http_message.c +++ b/http_message.c @@ -45,21 +45,6 @@ static const zend_module_dep deps[] = { {NULL, NULL, NULL} }; -zend_module_entry http_message_module_entry = { - STANDARD_MODULE_HEADER_EX, - NULL, - deps, - PHP_HTTP_MESSAGE_EXTNAME, - NULL, - PHP_MINIT(http_message), - NULL, - NULL, - NULL, - NULL, - PHP_HTTP_MESSAGE_VERSION, - STANDARD_MODULE_PROPERTIES -}; - PHP_MINIT_FUNCTION(http_message) { int success = @@ -76,6 +61,21 @@ PHP_MINIT_FUNCTION(http_message) return ZEND_NORMALIZE_BOOL(success); } +zend_module_entry http_message_module_entry = { + STANDARD_MODULE_HEADER_EX, + NULL, + deps, + PHP_HTTP_MESSAGE_EXTNAME, + NULL, + PHP_MINIT(http_message), + NULL, + NULL, + NULL, + NULL, + PHP_HTTP_MESSAGE_VERSION, + STANDARD_MODULE_PROPERTIES +}; + #ifdef COMPILE_DL_HTTP_MESSAGE ZEND_GET_MODULE(http_message) #endif diff --git a/php_http_message.h b/php_http_message.h index 80e419f..7df8474 100644 --- a/php_http_message.h +++ b/php_http_message.h @@ -42,9 +42,6 @@ # define PHP_HTTP_MESSAGE_API #endif -static PHP_MINFO_FUNCTION(http_message); -static PHP_MINIT_FUNCTION(http_message); - extern PHP_MINIT_FUNCTION(http_message_message); extern PHP_MINIT_FUNCTION(http_message_request); extern PHP_MINIT_FUNCTION(http_message_serverrequest); From a33ecedec096137de5b5b1715c95e8afeee67528 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Wed, 26 Aug 2020 11:15:40 +0200 Subject: [PATCH 2/3] fix unused build warnings --- request.c | 4 ++-- response.c | 2 ++ server_request.c | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/request.c b/request.c index 2b1cfd8..b6a8524 100644 --- a/request.c +++ b/request.c @@ -47,8 +47,10 @@ zend_class_entry *HttpMessage_Request_ce = NULL; /* __construct */ +/* unused ZEND_BEGIN_ARG_INFO_EX(arginfo_Request_construct, 0, 0, 0) ZEND_END_ARG_INFO() +*/ PHP_METHOD(Request, __construct) { @@ -129,12 +131,10 @@ PHP_METHOD(Request, getMethod) PHP_METHOD(Request, withMethod) { - int u; zend_string *value = NULL; ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_THROW, 1, 1) Z_PARAM_STR(value) - u = _i + 5; ZEND_PARSE_PARAMETERS_END(); ZVAL_OBJ(return_value, zend_objects_clone_obj(getThis())); diff --git a/response.c b/response.c index 0bb9a2f..ed226be 100644 --- a/response.c +++ b/response.c @@ -71,10 +71,12 @@ int response_set_status(zval *obj, zend_long code, zend_string *phrase) /* __construct */ +/* unused ZEND_BEGIN_ARG_INFO_EX(arginfo_HttpMessageServerRequest_construct, 0, 0, 0) ZEND_ARG_TYPE_INFO(0, statusCode, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, reasonPhrase, IS_STRING, 0) ZEND_END_ARG_INFO() +*/ PHP_METHOD(Response, __construct) { diff --git a/server_request.c b/server_request.c index 6b110ff..9d9116f 100644 --- a/server_request.c +++ b/server_request.c @@ -115,6 +115,7 @@ void init_headers_from_params(zval *object, HashTable *serverParams) headers = Z_ARR_P(zend_read_property(HttpMessage_Message_ce, object, ZEND_STRL("headers"), 0, &rv)); ZEND_HASH_FOREACH_KEY_VAL(serverParams, index, key, val) { + (void)index; /* NOOP, to avoid unused warning */ if (UNEXPECTED(key == NULL)) continue; if (ZSTR_LEN(key) > 5 && strncmp("HTTP_", ZSTR_VAL(key), 5) == 0 && EXPECTED(Z_TYPE_P(val) == IS_STRING)) { From 787594dae4509287ae7d26b53e5edf0000f8624d Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Wed, 26 Aug 2020 12:13:53 +0200 Subject: [PATCH 3/3] fix for PHP 8.0.0beta3 --- emitter.c | 22 +++--- factory.c | 8 +-- macros.h | 22 +++--- message.c | 37 +++++----- request.c | 30 ++++---- response.c | 12 ++-- server_request.c | 58 +++++++-------- stream.c | 32 ++++----- tests/Factory/createResponse_err01.phpt | 6 +- tests/Factory/createServerRequest_err01.phpt | 4 +- tests/Factory/createStreamFromFile_002.phpt | 6 +- tests/Factory/createStreamFromFile_err01.phpt | 6 +- tests/Factory/createStream_err01.phpt | 4 +- tests/Factory/createUploadedFile_err01.phpt | 14 ++-- tests/Message/body_err01.phpt | 4 +- tests/Message/headers_err01.phpt | 6 +- tests/Message/headers_err02.phpt | 6 +- tests/Message/headers_err03.phpt | 6 +- tests/Message/headers_err04.phpt | 6 +- tests/Message/headers_err05.phpt | 6 +- tests/Message/protocolVersion_err01.phpt | 4 +- tests/Request/method_err01.phpt | 4 +- tests/Request/requestTarget_err01.phpt | 4 +- tests/Request/uri_err01.phpt | 4 +- tests/Response/status_err01.phpt | 6 +- tests/ServerRequest/__construct_err01.phpt | 14 ++-- tests/ServerRequest/attributes_err01.phpt | 4 +- tests/ServerRequest/cookieParams_err01.phpt | 4 +- tests/ServerRequest/parsedBody_err01.phpt | 4 +- tests/ServerRequest/queryParams_err01.phpt | 4 +- tests/Stream/read_err02.phpt | 2 +- tests/Stream/seek_err02.phpt | 4 +- tests/Stream/write_err02.phpt | 4 +- tests/UploadedFile/__construct_err01.phpt | 12 ++-- tests/UploadedFile/moveTo_err03.phpt | 4 +- tests/UploadedFile/moveTo_err05.phpt | 2 +- tests/Uri/__construct_err01.phpt | 4 +- tests/Uri/fragment_err01.phpt | 4 +- tests/Uri/host_error.phpt | 4 +- tests/Uri/path_err01.phpt | 4 +- tests/Uri/port_err01.phpt | 2 +- tests/Uri/query_err01.phpt | 4 +- tests/Uri/scheme_err01.phpt | 4 +- tests/Uri/userInfo_err01.phpt | 4 +- uploaded_file.c | 42 +++++------ uri.c | 70 +++++++++---------- 46 files changed, 263 insertions(+), 254 deletions(-) diff --git a/emitter.c b/emitter.c index 10933ff..7003918 100644 --- a/emitter.c +++ b/emitter.c @@ -70,10 +70,10 @@ int read_response_body(zval *response, zval *contents) ZVAL_NULL(&body); ZVAL_NULL(contents); - zend_call_method_with_0_params(response, NULL, NULL, "getBody", &body); + zend_call_method_with_0_params(PROPERTY_ARG(response), NULL, NULL, "getBody", &body); if (EXPECTED(Z_TYPE(body) == IS_OBJECT)) { - zend_call_method_with_0_params(&body, NULL, NULL, "__toString", contents); + zend_call_method_with_0_params(PROPERTY_ARG(&body), NULL, NULL, "__toString", contents); } if (UNEXPECTED(Z_TYPE_P(contents) != IS_STRING)) { @@ -94,9 +94,9 @@ void emit_status(zval *response) ZVAL_NULL(&status_code); ZVAL_NULL(&reason_phrase); - zend_call_method_with_0_params(response, NULL, NULL, "getProtocolVersion", &version); - zend_call_method_with_0_params(response, NULL, NULL, "getStatusCode", &status_code); - zend_call_method_with_0_params(response, NULL, NULL, "getReasonPhrase", &reason_phrase); + zend_call_method_with_0_params(PROPERTY_ARG(response), NULL, NULL, "getProtocolVersion", &version); + zend_call_method_with_0_params(PROPERTY_ARG(response), NULL, NULL, "getStatusCode", &status_code); + zend_call_method_with_0_params(PROPERTY_ARG(response), NULL, NULL, "getReasonPhrase", &reason_phrase); code = Z_LVAL(status_code); @@ -110,12 +110,12 @@ void emit_status(zval *response) ctr.line_len = Z_STRLEN(version) + phrase_len + 10; ctr.line = emalloc(ctr.line_len); - zend_sprintf(ctr.line, "HTTP/%.*s %3lu %.*s", (int)Z_STRLEN(version), Z_STRVAL(version), code, (int)phrase_len, phrase); + zend_sprintf((char *)ctr.line, "HTTP/%.*s %3lu %.*s", (int)Z_STRLEN(version), Z_STRVAL(version), code, (int)phrase_len, phrase); ctr.response_code = code; sapi_header_op(SAPI_HEADER_REPLACE, &ctr); - efree(ctr.line); + efree((char *)ctr.line); } void emit_header(zend_string *header_name, zend_array *header_lines) @@ -130,16 +130,16 @@ void emit_header(zend_string *header_name, zend_array *header_lines) // Reuse ctr: resize if needed. if (ctr.line_len >= max_header_size) { - efree(ctr.line); + efree((char *)ctr.line); max_header_size = (ctr.line_len + 255) - ((ctr.line_len + 255) % 256); ctr.line = emalloc(max_header_size); } - zend_sprintf(ctr.line, "%s: %s", ZSTR_VAL(header_name), Z_STRVAL_P(header_line)); + zend_sprintf((char *)ctr.line, "%s: %s", ZSTR_VAL(header_name), Z_STRVAL_P(header_line)); sapi_header_op(SAPI_HEADER_ADD, &ctr); } ZEND_HASH_FOREACH_END(); - efree(ctr.line); + efree((char *)ctr.line); } void emit_headers(zval *response) @@ -149,7 +149,7 @@ void emit_headers(zval *response) zend_string *header_name; zend_long index; - zend_call_method_with_0_params(response, NULL, NULL, "getHeaders", &headers); + zend_call_method_with_0_params(PROPERTY_ARG(response), NULL, NULL, "getHeaders", &headers); ZEND_HASH_FOREACH_KEY_VAL(Z_ARR(headers), index, header_name, header_lines) { if (UNEXPECTED(header_name == NULL)) { diff --git a/factory.c b/factory.c index 9cd556c..003e063 100644 --- a/factory.c +++ b/factory.c @@ -82,8 +82,8 @@ PHP_METHOD(Factory, createRequest) if (uri_param_as_object(uri) == FAILURE) return; NEW_OBJECT_CONSTRUCT(return_value, HttpMessage_Request_ce, 0); - zend_update_property_str(HttpMessage_Request_ce, return_value, ZEND_STRL("method"), method); - zend_update_property(HttpMessage_Request_ce, return_value, ZEND_STRL("uri"), uri); + zend_update_property_str(HttpMessage_Request_ce, PROPERTY_ARG(return_value), ZEND_STRL("method"), method); + zend_update_property(HttpMessage_Request_ce, PROPERTY_ARG(return_value), ZEND_STRL("uri"), uri); } PHP_METHOD(Factory, createResponse) @@ -122,8 +122,8 @@ PHP_METHOD(Factory, createServerRequest) NEW_OBJECT_CONSTRUCT(return_value, HttpMessage_ServerRequest_ce, 1, serverParams); } - zend_update_property_str(HttpMessage_ServerRequest_ce, return_value, ZEND_STRL("method"), method); - zend_update_property(HttpMessage_ServerRequest_ce, return_value, ZEND_STRL("uri"), uri); + zend_update_property_str(HttpMessage_ServerRequest_ce, PROPERTY_ARG(return_value), ZEND_STRL("method"), method); + zend_update_property(HttpMessage_ServerRequest_ce, PROPERTY_ARG(return_value), ZEND_STRL("uri"), uri); } PHP_METHOD(Factory, createStream) diff --git a/macros.h b/macros.h index 58af012..4be105b 100644 --- a/macros.h +++ b/macros.h @@ -35,21 +35,27 @@ #define EXPAND( x ) x +#if PHP_VERSION_ID < 80000 +#define PROPERTY_ARG(zv) (zv) +#else +#define PROPERTY_ARG(zv) Z_OBJ_P(zv) +#endif + ZEND_BEGIN_ARG_INFO_EX(arginfo_none, 0, 0, 0) ZEND_END_ARG_INFO() #define INIT_ARRAY_PROPERTY(className, property, rv) \ - array_init(zend_read_property(className, getThis(), ZEND_STRL(property), 0, &rv)) + array_init(zend_read_property(className, PROPERTY_ARG(getThis()), ZEND_STRL(property), 0, &rv)) #define SET_ARRAY_PROPERTY(className, property, zval, rv) \ - if (zval == NULL) array_init(zend_read_property(className, getThis(), ZEND_STRL(property), 0, &rv)); \ - else zend_update_property(className, getThis(), ZEND_STRL(property), zval) + if (zval == NULL) array_init(zend_read_property(className, PROPERTY_ARG(getThis()), ZEND_STRL(property), 0, &rv)); \ + else zend_update_property(className, PROPERTY_ARG(getThis()), ZEND_STRL(property), zval) #define SET_STRING_PROPERTY(className, property, val) \ - if (val != NULL) zend_update_property_stringl(className, getThis(), ZEND_STRL(property), val, strlen(val)) + if (val != NULL) zend_update_property_stringl(className, PROPERTY_ARG(getThis()), ZEND_STRL(property), val, strlen(val)) #define SET_STR_PROPERTY(className, property, val) \ - if (val != NULL) zend_update_property_str(className, getThis(), ZEND_STRL(property), val) + if (val != NULL) zend_update_property_str(className, PROPERTY_ARG(getThis()), ZEND_STRL(property), val) #if PHP_VERSION_ID < 70300 #define SET_URI_PROPERTY(className, property, val) SET_STRING_PROPERTY(className, property, val) @@ -73,7 +79,7 @@ ZEND_END_ARG_INFO() #define NEW_OBJECT_CONSTRUCT(zval, ce, argc, ...) \ NEW_OBJECT(zval, ce); \ if (EXPECTED(zval != NULL)) \ - EXPAND(zend_call_method_with_## argc ##_params(zval, ce, &ce->constructor, "__construct", NULL, ## __VA_ARGS__)) + EXPAND(zend_call_method_with_## argc ##_params(PROPERTY_ARG(zval), ce, &ce->constructor, "__construct", NULL, ## __VA_ARGS__)) #define IS_STREAM_RESOURCE(zstream) \ ( \ @@ -87,10 +93,10 @@ ZEND_END_ARG_INFO() #define ARRAY_GET(arr, index, key) \ arr != NULL ? (key == NULL ? zend_hash_index_find(arr, index) : zend_hash_find(arr, key)) : NULL -#define COPY_PROPERTY_FROM_ARRAY(arr, key, className, object, property, type, val) \ +#define COPY_PROPERTY_FROM_ARRAY(arr, key, object, className, property, type, val) \ val = zend_hash_str_find(arr, ZEND_STRL(key)); \ if (val != NULL && EXPECTED(Z_TYPE_P(val) == type)) { \ - zend_update_property(object, className, ZEND_STRL(property), val); \ + zend_update_property(className, PROPERTY_ARG(object), ZEND_STRL(property), val); \ } #define Z_ARR_P_NULL(zval) zval != NULL ? Z_ARR_P(zval) : NULL diff --git a/message.c b/message.c index 8df39c8..5d4d38a 100644 --- a/message.c +++ b/message.c @@ -50,7 +50,7 @@ void add_header(zval *object, zend_string *name, zend_string *value, zend_bool a zval rv, *headers_prop, *header_values; HashTable *headers; - headers_prop = zend_read_property(HttpMessage_Message_ce, object, ZEND_STRL("headers"), 0, &rv); + headers_prop = zend_read_property(HttpMessage_Message_ce, PROPERTY_ARG(object), ZEND_STRL("headers"), 0, &rv); if (UNEXPECTED(Z_TYPE_P(headers_prop) != IS_ARRAY)) { return; // Shouldn't happen @@ -78,7 +78,7 @@ PHP_METHOD(Message, __construct) zval rv, *body; /* $this->body = new Stream() */ - body = zend_read_property(HttpMessage_Message_ce, getThis(), ZEND_STRL("body"), 0, &rv); + body = zend_read_property(HttpMessage_Message_ce, PROPERTY_ARG(getThis()), ZEND_STRL("body"), 0, &rv); NEW_OBJECT_CONSTRUCT(body, HttpMessage_Stream_ce, 0); INIT_ARRAY_PROPERTY(HttpMessage_Message_ce, "headers", rv); @@ -91,7 +91,7 @@ PHP_METHOD(Message, getProtocolVersion) { zval rv, *value; - value = zend_read_property(HttpMessage_Message_ce, getThis(), ZEND_STRL("protocolVersion"), 0, &rv); + value = zend_read_property(HttpMessage_Message_ce, PROPERTY_ARG(getThis()), ZEND_STRL("protocolVersion"), 0, &rv); RETURN_ZVAL(value, 1, 0); } @@ -104,9 +104,9 @@ PHP_METHOD(Message, withProtocolVersion) Z_PARAM_STR(value) ZEND_PARSE_PARAMETERS_END(); - ZVAL_OBJ(return_value, zend_objects_clone_obj(getThis())); + ZVAL_OBJ(return_value, zend_objects_clone_obj(PROPERTY_ARG(getThis()))); - zend_update_property_str(HttpMessage_Message_ce, return_value, ZEND_STRL("protocolVersion"), value); + zend_update_property_str(HttpMessage_Message_ce, PROPERTY_ARG(return_value), ZEND_STRL("protocolVersion"), value); } @@ -116,7 +116,7 @@ PHP_METHOD(Message, getHeaders) { zval rv, *headers; - headers = zend_read_property(HttpMessage_Message_ce, getThis(), ZEND_STRL("headers"), 0, &rv); + headers = zend_read_property(HttpMessage_Message_ce, PROPERTY_ARG(getThis()), ZEND_STRL("headers"), 0, &rv); RETURN_ZVAL(headers, 1, 0); } @@ -131,7 +131,7 @@ PHP_METHOD(Message, hasHeader) Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); - headers = zend_read_property(HttpMessage_Message_ce, getThis(), ZEND_STRL("headers"), 0, &rv); + headers = zend_read_property(HttpMessage_Message_ce, PROPERTY_ARG(getThis()), ZEND_STRL("headers"), 0, &rv); exists = zend_hash_exists(Z_ARRVAL_P(headers), name); RETVAL_BOOL(exists); @@ -146,7 +146,7 @@ PHP_METHOD(Message, getHeader) Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); - headers = zend_read_property(HttpMessage_Message_ce, getThis(), ZEND_STRL("headers"), 0, &rv); + headers = zend_read_property(HttpMessage_Message_ce, PROPERTY_ARG(getThis()), ZEND_STRL("headers"), 0, &rv); header_values = zend_hash_find(Z_ARRVAL_P(headers), name); if (header_values == NULL) { @@ -166,7 +166,7 @@ PHP_METHOD(Message, getHeaderLine) Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); - headers = zend_read_property(HttpMessage_Message_ce, getThis(), ZEND_STRL("headers"), 0, &rv); + headers = zend_read_property(HttpMessage_Message_ce, PROPERTY_ARG(getThis()), ZEND_STRL("headers"), 0, &rv); header_values = zend_hash_find(Z_ARRVAL_P(headers), name); if (header_values == NULL) { @@ -174,8 +174,11 @@ PHP_METHOD(Message, getHeaderLine) } glue = zend_string_init(ZEND_STRL(", "), 0); +#if PHP_VERSION_ID < 80000 php_implode(glue, header_values, return_value); - +#else + php_implode(glue, Z_ARRVAL_P(header_values), return_value); +#endif zend_string_free(glue); } @@ -188,7 +191,7 @@ PHP_METHOD(Message, withHeader) Z_PARAM_STR(value) ZEND_PARSE_PARAMETERS_END(); - ZVAL_OBJ(return_value, zend_objects_clone_obj(getThis())); + ZVAL_OBJ(return_value, zend_objects_clone_obj(PROPERTY_ARG(getThis()))); add_header(return_value, name, value, 0); } @@ -202,7 +205,7 @@ PHP_METHOD(Message, withAddedHeader) Z_PARAM_STR(value) ZEND_PARSE_PARAMETERS_END(); - ZVAL_OBJ(return_value, zend_objects_clone_obj(getThis())); + ZVAL_OBJ(return_value, zend_objects_clone_obj(PROPERTY_ARG(getThis()))); add_header(return_value, name, value, 1); } @@ -217,9 +220,9 @@ PHP_METHOD(Message, withoutHeader) Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); - ZVAL_OBJ(return_value, zend_objects_clone_obj(getThis())); + ZVAL_OBJ(return_value, zend_objects_clone_obj(PROPERTY_ARG(getThis()))); - headers_prop = zend_read_property(HttpMessage_Message_ce, return_value, ZEND_STRL("headers"), 0, &rv); + headers_prop = zend_read_property(HttpMessage_Message_ce, PROPERTY_ARG(return_value), ZEND_STRL("headers"), 0, &rv); headers = zend_array_dup(Z_ARR_P(headers_prop)); zend_hash_del(headers, name); @@ -234,7 +237,7 @@ PHP_METHOD(Message, getBody) { zval rv, *value; - value = zend_read_property(HttpMessage_Message_ce, getThis(), ZEND_STRL("body"), 0, &rv); + value = zend_read_property(HttpMessage_Message_ce, PROPERTY_ARG(getThis()), ZEND_STRL("body"), 0, &rv); RETURN_ZVAL(value, 1, 0); } @@ -253,9 +256,9 @@ PHP_METHOD(Message, withBody) Z_PARAM_OBJECT_OF_CLASS(value, stream_interface) ZEND_PARSE_PARAMETERS_END(); - ZVAL_OBJ(return_value, zend_objects_clone_obj(getThis())); + ZVAL_OBJ(return_value, zend_objects_clone_obj(PROPERTY_ARG(getThis()))); - zend_update_property(HttpMessage_Message_ce, return_value, ZEND_STRL("body"), value); + zend_update_property(HttpMessage_Message_ce, PROPERTY_ARG(return_value), ZEND_STRL("body"), value); } diff --git a/request.c b/request.c index b6a8524..63e4af6 100644 --- a/request.c +++ b/request.c @@ -58,11 +58,11 @@ PHP_METHOD(Request, __construct) /* parent::__construct() */ zend_call_method_with_0_params( - getThis(), HttpMessage_Message_ce, &HttpMessage_Message_ce->constructor, "__construct", NULL + PROPERTY_ARG(getThis()), HttpMessage_Message_ce, &HttpMessage_Message_ce->constructor, "__construct", NULL ); /* $this->uri = new Uri() */ - uri = zend_read_property(HttpMessage_Request_ce, getThis(), ZEND_STRL("uri"), 0, &rv); + uri = zend_read_property(HttpMessage_Request_ce, PROPERTY_ARG(getThis()), ZEND_STRL("uri"), 0, &rv); NEW_OBJECT(uri, HttpMessage_Uri_ce); } @@ -74,15 +74,15 @@ PHP_METHOD(Request, getRequestTarget) zval rv, *value, *uri, path, query; smart_str buf = {0}; - value = zend_read_property(HttpMessage_Request_ce, getThis(), ZEND_STRL("requestTarget"), 0, &rv); + value = zend_read_property(HttpMessage_Request_ce, PROPERTY_ARG(getThis()), ZEND_STRL("requestTarget"), 0, &rv); if (!ZVAL_IS_NULL(value)) { RETURN_ZVAL(value, 1, 0); } - uri = zend_read_property(HttpMessage_Request_ce, getThis(), ZEND_STRL("uri"), 0, &rv); - zend_call_method_with_0_params(uri, NULL, NULL, "getPath", &path); - zend_call_method_with_0_params(uri, NULL, NULL, "getQuery", &query); + uri = zend_read_property(HttpMessage_Request_ce, PROPERTY_ARG(getThis()), ZEND_STRL("uri"), 0, &rv); + zend_call_method_with_0_params(PROPERTY_ARG(uri), NULL, NULL, "getPath", &path); + zend_call_method_with_0_params(PROPERTY_ARG(uri), NULL, NULL, "getQuery", &query); if (UNEXPECTED(Z_TYPE(path) != IS_STRING) || Z_STRLEN(path) == 0) { RETURN_STRING("/"); @@ -108,12 +108,12 @@ PHP_METHOD(Request, withRequestTarget) Z_PARAM_STR_EX(value, 1, 0) ZEND_PARSE_PARAMETERS_END(); - ZVAL_OBJ(return_value, zend_objects_clone_obj(getThis())); + ZVAL_OBJ(return_value, zend_objects_clone_obj(PROPERTY_ARG(getThis()))); if (EXPECTED(value != NULL)) { - zend_update_property_str(HttpMessage_Request_ce, return_value, ZEND_STRL("requestTarget"), value); + zend_update_property_str(HttpMessage_Request_ce, PROPERTY_ARG(return_value), ZEND_STRL("requestTarget"), value); } else { - zend_update_property_null(HttpMessage_Request_ce, return_value, ZEND_STRL("requestTarget")); + zend_update_property_null(HttpMessage_Request_ce, PROPERTY_ARG(return_value), ZEND_STRL("requestTarget")); } } @@ -124,7 +124,7 @@ PHP_METHOD(Request, getMethod) { zval rv, *value; - value = zend_read_property(HttpMessage_Request_ce, getThis(), ZEND_STRL("method"), 0, &rv); + value = zend_read_property(HttpMessage_Request_ce, PROPERTY_ARG(getThis()), ZEND_STRL("method"), 0, &rv); RETURN_ZVAL(value, 1, 0); } @@ -137,9 +137,9 @@ PHP_METHOD(Request, withMethod) Z_PARAM_STR(value) ZEND_PARSE_PARAMETERS_END(); - ZVAL_OBJ(return_value, zend_objects_clone_obj(getThis())); + ZVAL_OBJ(return_value, zend_objects_clone_obj(PROPERTY_ARG(getThis()))); - zend_update_property_str(HttpMessage_Request_ce, return_value, ZEND_STRL("method"), value); + zend_update_property_str(HttpMessage_Request_ce, PROPERTY_ARG(return_value), ZEND_STRL("method"), value); } @@ -149,7 +149,7 @@ PHP_METHOD(Request, getUri) { zval rv, *value; - value = zend_read_property(HttpMessage_Request_ce, getThis(), ZEND_STRL("uri"), 0, &rv); + value = zend_read_property(HttpMessage_Request_ce, PROPERTY_ARG(getThis()), ZEND_STRL("uri"), 0, &rv); RETURN_ZVAL(value, 1, 0); } @@ -168,9 +168,9 @@ PHP_METHOD(Request, withUri) Z_PARAM_OBJECT_OF_CLASS(value, uri_interface) ZEND_PARSE_PARAMETERS_END(); - ZVAL_OBJ(return_value, zend_objects_clone_obj(getThis())); + ZVAL_OBJ(return_value, zend_objects_clone_obj(PROPERTY_ARG(getThis()))); - zend_update_property(HttpMessage_Request_ce, return_value, ZEND_STRL("uri"), value); + zend_update_property(HttpMessage_Request_ce, PROPERTY_ARG(return_value), ZEND_STRL("uri"), value); } diff --git a/response.c b/response.c index ed226be..9787501 100644 --- a/response.c +++ b/response.c @@ -54,14 +54,14 @@ int response_set_status(zval *obj, zend_long code, zend_string *phrase) return FAILURE; } - zend_update_property_long(HttpMessage_Response_ce, obj, ZEND_STRL("statusCode"), code); + zend_update_property_long(HttpMessage_Response_ce, PROPERTY_ARG(obj), ZEND_STRL("statusCode"), code); if (phrase != NULL) { - zend_update_property_str(HttpMessage_Response_ce, obj, ZEND_STRL("reasonPhrase"), phrase); + zend_update_property_str(HttpMessage_Response_ce, PROPERTY_ARG(obj), ZEND_STRL("reasonPhrase"), phrase); } else { suggested_phrase = get_status_string((int)code); zend_update_property_stringl( - HttpMessage_Response_ce, obj, ZEND_STRL("reasonPhrase"), + HttpMessage_Response_ce, PROPERTY_ARG(obj), ZEND_STRL("reasonPhrase"), suggested_phrase, strlen(suggested_phrase) ); } @@ -101,7 +101,7 @@ PHP_METHOD(Response, getStatusCode) { zval rv, *value; - value = zend_read_property(HttpMessage_Response_ce, getThis(), ZEND_STRL("statusCode"), 0, &rv); + value = zend_read_property(HttpMessage_Response_ce, PROPERTY_ARG(getThis()), ZEND_STRL("statusCode"), 0, &rv); RETURN_ZVAL(value, 1, 0); } @@ -110,7 +110,7 @@ PHP_METHOD(Response, getReasonPhrase) { zval rv, *value; - value = zend_read_property(HttpMessage_Response_ce, getThis(), ZEND_STRL("reasonPhrase"), 0, &rv); + value = zend_read_property(HttpMessage_Response_ce, PROPERTY_ARG(getThis()), ZEND_STRL("reasonPhrase"), 0, &rv); RETURN_ZVAL(value, 1, 0); } @@ -126,7 +126,7 @@ PHP_METHOD(Response, withStatus) Z_PARAM_STR_EX(phrase, 1, 0) ZEND_PARSE_PARAMETERS_END(); - ZVAL_OBJ(return_value, zend_objects_clone_obj(getThis())); + ZVAL_OBJ(return_value, zend_objects_clone_obj(PROPERTY_ARG(getThis()))); response_set_status(return_value, code, phrase); } diff --git a/server_request.c b/server_request.c index 9d9116f..5a99409 100644 --- a/server_request.c +++ b/server_request.c @@ -112,7 +112,7 @@ void init_headers_from_params(zval *object, HashTable *serverParams) zend_long index; zend_string *key; - headers = Z_ARR_P(zend_read_property(HttpMessage_Message_ce, object, ZEND_STRL("headers"), 0, &rv)); + headers = Z_ARR_P(zend_read_property(HttpMessage_Message_ce, PROPERTY_ARG(object), ZEND_STRL("headers"), 0, &rv)); ZEND_HASH_FOREACH_KEY_VAL(serverParams, index, key, val) { (void)index; /* NOOP, to avoid unused warning */ @@ -140,10 +140,10 @@ void init_uri_from_params(zval *object, HashTable *serverParams) zend_long port = -1, default_port = -1; zend_bool is_http; - uri = zend_read_property(HttpMessage_Request_ce, object, ZEND_STRL("uri"), 0, &rv); + uri = zend_read_property(HttpMessage_Request_ce, PROPERTY_ARG(object), ZEND_STRL("uri"), 0, &rv); request_target = zend_hash_str_find(serverParams, ZEND_STRL("REQUEST_URI")); - zend_call_method(uri, HttpMessage_Uri_ce, &HttpMessage_Uri_ce->constructor, ZEND_STRL("__construct"), NULL, + zend_call_method(PROPERTY_ARG(uri), HttpMessage_Uri_ce, &HttpMessage_Uri_ce->constructor, ZEND_STRL("__construct"), NULL, request_target == NULL ? 0 : 1, request_target, NULL); COPY_PROPERTY_FROM_ARRAY(serverParams, "HTTP_HOST", uri, HttpMessage_Uri_ce, "host", IS_STRING, tmp); @@ -164,14 +164,14 @@ void init_uri_from_params(zval *object, HashTable *serverParams) // do nothing } else if (Z_STRCMP(https, "off", 0) == 0) { default_port = 80; - zend_update_property_stringl(HttpMessage_Uri_ce, uri, ZEND_STRL("scheme"), ZEND_STRL("http")); + zend_update_property_stringl(HttpMessage_Uri_ce, PROPERTY_ARG(uri), ZEND_STRL("scheme"), ZEND_STRL("http")); } else { default_port = 443; - zend_update_property_stringl(HttpMessage_Uri_ce, uri, ZEND_STRL("scheme"), ZEND_STRL("https")); + zend_update_property_stringl(HttpMessage_Uri_ce, PROPERTY_ARG(uri), ZEND_STRL("scheme"), ZEND_STRL("https")); } if (port != default_port && port > 0) { - zend_update_property_long(HttpMessage_Uri_ce, uri, ZEND_STRL("port"), port); + zend_update_property_long(HttpMessage_Uri_ce, PROPERTY_ARG(uri), ZEND_STRL("port"), port); } user = zend_hash_str_find(serverParams, ZEND_STRL("PHP_AUTH_USER")); @@ -207,7 +207,7 @@ PHP_METHOD(ServerRequest, __construct) /* parent::__construct() */ zend_call_method_with_0_params( - getThis(), HttpMessage_Request_ce, &HttpMessage_Request_ce->constructor, "__construct", NULL + PROPERTY_ARG(getThis()), HttpMessage_Request_ce, &HttpMessage_Request_ce->constructor, "__construct", NULL ); SET_ARRAY_PROPERTY(HttpMessage_ServerRequest_ce, "serverParams", serverParams, rv); @@ -215,14 +215,14 @@ PHP_METHOD(ServerRequest, __construct) SET_ARRAY_PROPERTY(HttpMessage_ServerRequest_ce, "queryParams", queryParams, rv); if (files != NULL) { - uploadedFiles = zend_read_property(HttpMessage_ServerRequest_ce, getThis(), ZEND_STRL("uploadedFiles"), 0, &rv); + uploadedFiles = zend_read_property(HttpMessage_ServerRequest_ce, PROPERTY_ARG(getThis()), ZEND_STRL("uploadedFiles"), 0, &rv); create_uploaded_files(uploadedFiles, Z_ARR_P(files)); } else { INIT_ARRAY_PROPERTY(HttpMessage_ServerRequest_ce, "uploadedFiles", rv); } if (post != NULL) { - zend_update_property(HttpMessage_ServerRequest_ce, getThis(), ZEND_STRL("parsedBody"), post); + zend_update_property(HttpMessage_ServerRequest_ce, PROPERTY_ARG(getThis()), ZEND_STRL("parsedBody"), post); } if (serverParams != NULL) { @@ -242,7 +242,7 @@ PHP_METHOD(ServerRequest, getServerParams) { zval rv, *value; - value = zend_read_property(HttpMessage_ServerRequest_ce, getThis(), ZEND_STRL("serverParams"), 0, &rv); + value = zend_read_property(HttpMessage_ServerRequest_ce, PROPERTY_ARG(getThis()), ZEND_STRL("serverParams"), 0, &rv); RETURN_ZVAL(value, 1, 0); } @@ -254,7 +254,7 @@ PHP_METHOD(ServerRequest, getCookieParams) { zval rv, *value; - value = zend_read_property(HttpMessage_ServerRequest_ce, getThis(), ZEND_STRL("cookieParams"), 0, &rv); + value = zend_read_property(HttpMessage_ServerRequest_ce, PROPERTY_ARG(getThis()), ZEND_STRL("cookieParams"), 0, &rv); RETURN_ZVAL(value, 1, 0); } @@ -267,9 +267,9 @@ PHP_METHOD(ServerRequest, withCookieParams) Z_PARAM_ARRAY(value); ZEND_PARSE_PARAMETERS_END(); - ZVAL_OBJ(return_value, zend_objects_clone_obj(getThis())); + ZVAL_OBJ(return_value, zend_objects_clone_obj(PROPERTY_ARG(getThis()))); - zend_update_property(HttpMessage_ServerRequest_ce, return_value, ZEND_STRL("cookieParams"), value); + zend_update_property(HttpMessage_ServerRequest_ce, PROPERTY_ARG(return_value), ZEND_STRL("cookieParams"), value); } @@ -279,7 +279,7 @@ PHP_METHOD(ServerRequest, getQueryParams) { zval rv, *value; - value = zend_read_property(HttpMessage_ServerRequest_ce, getThis(), ZEND_STRL("queryParams"), 0, &rv); + value = zend_read_property(HttpMessage_ServerRequest_ce, PROPERTY_ARG(getThis()), ZEND_STRL("queryParams"), 0, &rv); RETURN_ZVAL(value, 1, 0); } @@ -292,9 +292,9 @@ PHP_METHOD(ServerRequest, withQueryParams) Z_PARAM_ARRAY(value); ZEND_PARSE_PARAMETERS_END(); - ZVAL_OBJ(return_value, zend_objects_clone_obj(getThis())); + ZVAL_OBJ(return_value, zend_objects_clone_obj(PROPERTY_ARG(getThis()))); - zend_update_property(HttpMessage_ServerRequest_ce, return_value, ZEND_STRL("queryParams"), value); + zend_update_property(HttpMessage_ServerRequest_ce, PROPERTY_ARG(return_value), ZEND_STRL("queryParams"), value); } @@ -304,7 +304,7 @@ PHP_METHOD(ServerRequest, getUploadedFiles) { zval rv, *value; - value = zend_read_property(HttpMessage_ServerRequest_ce, getThis(), ZEND_STRL("uploadedFiles"), 0, &rv); + value = zend_read_property(HttpMessage_ServerRequest_ce, PROPERTY_ARG(getThis()), ZEND_STRL("uploadedFiles"), 0, &rv); RETURN_ZVAL(value, 1, 0); } @@ -321,9 +321,9 @@ PHP_METHOD(ServerRequest, withUploadedFiles) return; } - ZVAL_OBJ(return_value, zend_objects_clone_obj(getThis())); + ZVAL_OBJ(return_value, zend_objects_clone_obj(PROPERTY_ARG(getThis()))); - zend_update_property(HttpMessage_ServerRequest_ce, return_value, ZEND_STRL("uploadedFiles"), value); + zend_update_property(HttpMessage_ServerRequest_ce, PROPERTY_ARG(return_value), ZEND_STRL("uploadedFiles"), value); } @@ -333,7 +333,7 @@ PHP_METHOD(ServerRequest, getParsedBody) { zval rv, *value; - value = zend_read_property(HttpMessage_ServerRequest_ce, getThis(), ZEND_STRL("parsedBody"), 0, &rv); + value = zend_read_property(HttpMessage_ServerRequest_ce, PROPERTY_ARG(getThis()), ZEND_STRL("parsedBody"), 0, &rv); RETURN_ZVAL(value, 1, 0); } @@ -346,12 +346,12 @@ PHP_METHOD(ServerRequest, withParsedBody) Z_PARAM_ARRAY_OR_OBJECT_EX(value, 1, 0); ZEND_PARSE_PARAMETERS_END(); - ZVAL_OBJ(return_value, zend_objects_clone_obj(getThis())); + ZVAL_OBJ(return_value, zend_objects_clone_obj(PROPERTY_ARG(getThis()))); if (EXPECTED(value != NULL)) { - zend_update_property(HttpMessage_ServerRequest_ce, return_value, ZEND_STRL("parsedBody"), value); + zend_update_property(HttpMessage_ServerRequest_ce, PROPERTY_ARG(return_value), ZEND_STRL("parsedBody"), value); } else { - zend_update_property_null(HttpMessage_ServerRequest_ce, return_value, ZEND_STRL("parsedBody")); + zend_update_property_null(HttpMessage_ServerRequest_ce, PROPERTY_ARG(return_value), ZEND_STRL("parsedBody")); } } @@ -362,7 +362,7 @@ PHP_METHOD(ServerRequest, getAttributes) { zval rv, *attributes; - attributes = zend_read_property(HttpMessage_ServerRequest_ce, getThis(), ZEND_STRL("attributes"), 0, &rv); + attributes = zend_read_property(HttpMessage_ServerRequest_ce, PROPERTY_ARG(getThis()), ZEND_STRL("attributes"), 0, &rv); RETURN_ZVAL(attributes, 1, 0); } @@ -378,7 +378,7 @@ PHP_METHOD(ServerRequest, getAttribute) Z_PARAM_ZVAL(default_value) ZEND_PARSE_PARAMETERS_END(); - attributes = zend_read_property(HttpMessage_ServerRequest_ce, getThis(), ZEND_STRL("attributes"), 0, &rv); + attributes = zend_read_property(HttpMessage_ServerRequest_ce, PROPERTY_ARG(getThis()), ZEND_STRL("attributes"), 0, &rv); value = zend_hash_find(Z_ARRVAL_P(attributes), name); @@ -403,9 +403,9 @@ PHP_METHOD(ServerRequest, withAttribute) Z_PARAM_ZVAL(value) ZEND_PARSE_PARAMETERS_END(); - ZVAL_OBJ(return_value, zend_objects_clone_obj(getThis())); + ZVAL_OBJ(return_value, zend_objects_clone_obj(PROPERTY_ARG(getThis()))); - attributes_prop = zend_read_property(HttpMessage_ServerRequest_ce, return_value, ZEND_STRL("attributes"), 0, &rv); + attributes_prop = zend_read_property(HttpMessage_ServerRequest_ce, PROPERTY_ARG(return_value), ZEND_STRL("attributes"), 0, &rv); attributes = zend_array_dup(Z_ARR_P(attributes_prop)); zend_symtable_update(attributes, name, value); @@ -422,9 +422,9 @@ PHP_METHOD(ServerRequest, withoutAttribute) Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); - ZVAL_OBJ(return_value, zend_objects_clone_obj(getThis())); + ZVAL_OBJ(return_value, zend_objects_clone_obj(PROPERTY_ARG(getThis()))); - attributes_prop = zend_read_property(HttpMessage_ServerRequest_ce, return_value, ZEND_STRL("attributes"), 0, &rv); + attributes_prop = zend_read_property(HttpMessage_ServerRequest_ce, PROPERTY_ARG(return_value), ZEND_STRL("attributes"), 0, &rv); attributes = zend_array_dup(Z_ARR_P(attributes_prop)); zend_symtable_del(attributes, name); diff --git a/stream.c b/stream.c index 963a2e2..226558f 100644 --- a/stream.c +++ b/stream.c @@ -49,7 +49,7 @@ void stream_seek(zval *this, zend_long offset, zend_long whence, zval* return_va zval rv, *resource; php_stream *stream; - resource = zend_read_property(HttpMessage_Stream_ce, this, ZEND_STRL("stream"), 0, &rv); + resource = zend_read_property(HttpMessage_Stream_ce, PROPERTY_ARG(this), ZEND_STRL("stream"), 0, &rv); if (!IS_STREAM_RESOURCE(resource)) { zend_throw_exception_ex(spl_ce_RuntimeException, 0, "Stream is %s", Z_TYPE_P(resource) == IS_RESOURCE ? "closed" : "detached"); @@ -115,7 +115,7 @@ PHP_METHOD(Stream, __construct) return; } - zend_update_property(HttpMessage_Stream_ce, getThis(), ZEND_STRL("stream"), &resource); + zend_update_property(HttpMessage_Stream_ce, PROPERTY_ARG(getThis()), ZEND_STRL("stream"), &resource); } PHP_METHOD(Stream, __toString) @@ -124,7 +124,7 @@ PHP_METHOD(Stream, __toString) php_stream *stream; zend_string *contents; - resource = zend_read_property(HttpMessage_Stream_ce, getThis(), ZEND_STRL("stream"), 0, &rv); + resource = zend_read_property(HttpMessage_Stream_ce, PROPERTY_ARG(getThis()), ZEND_STRL("stream"), 0, &rv); if (!IS_STREAM_RESOURCE(resource)) { RETURN_EMPTY_STRING(); } @@ -161,7 +161,7 @@ PHP_METHOD(Stream, close) zval rv, *resource; php_stream *stream; - resource = zend_read_property(HttpMessage_Stream_ce, getThis(), ZEND_STRL("stream"), 0, &rv); + resource = zend_read_property(HttpMessage_Stream_ce, PROPERTY_ARG(getThis()), ZEND_STRL("stream"), 0, &rv); if (Z_TYPE_P(resource) != IS_RESOURCE) { return; } @@ -176,10 +176,10 @@ PHP_METHOD(Stream, detach) { zval rv, *resource; - resource = zend_read_property(HttpMessage_Stream_ce, getThis(), ZEND_STRL("stream"), 0, &rv); + resource = zend_read_property(HttpMessage_Stream_ce, PROPERTY_ARG(getThis()), ZEND_STRL("stream"), 0, &rv); ZVAL_COPY(return_value, resource); - zend_update_property_null(HttpMessage_Stream_ce, getThis(), ZEND_STRL("stream")); + zend_update_property_null(HttpMessage_Stream_ce, PROPERTY_ARG(getThis()), ZEND_STRL("stream")); } PHP_METHOD(Stream, getSize) @@ -188,7 +188,7 @@ PHP_METHOD(Stream, getSize) php_stream *stream; php_stream_statbuf ssb; - resource = zend_read_property(HttpMessage_Stream_ce, getThis(), ZEND_STRL("stream"), 0, &rv); + resource = zend_read_property(HttpMessage_Stream_ce, PROPERTY_ARG(getThis()), ZEND_STRL("stream"), 0, &rv); if (!IS_STREAM_RESOURCE(resource)) { RETURN_NULL(); } @@ -205,7 +205,7 @@ PHP_METHOD(Stream, tell) php_stream *stream; size_t pos; - resource = zend_read_property(HttpMessage_Stream_ce, getThis(), ZEND_STRL("stream"), 0, &rv); + resource = zend_read_property(HttpMessage_Stream_ce, PROPERTY_ARG(getThis()), ZEND_STRL("stream"), 0, &rv); if (!IS_STREAM_RESOURCE(resource)) { zend_throw_exception_ex(spl_ce_RuntimeException, 0, "Stream is %s", Z_TYPE_P(resource) == IS_RESOURCE ? "closed" : "detached"); @@ -224,7 +224,7 @@ PHP_METHOD(Stream, eof) php_stream *stream; zend_bool eof; - resource = zend_read_property(HttpMessage_Stream_ce, getThis(), ZEND_STRL("stream"), 0, &rv); + resource = zend_read_property(HttpMessage_Stream_ce, PROPERTY_ARG(getThis()), ZEND_STRL("stream"), 0, &rv); if (!IS_STREAM_RESOURCE(resource)) { RETURN_TRUE; } @@ -241,7 +241,7 @@ PHP_METHOD(Stream, isSeekable) php_stream *stream; zend_bool seekable; - resource = zend_read_property(HttpMessage_Stream_ce, getThis(), ZEND_STRL("stream"), 0, &rv); + resource = zend_read_property(HttpMessage_Stream_ce, PROPERTY_ARG(getThis()), ZEND_STRL("stream"), 0, &rv); if (!IS_STREAM_RESOURCE(resource)) { RETURN_FALSE; } @@ -275,7 +275,7 @@ PHP_METHOD(Stream, isWritable) zval rv, *resource; php_stream *stream; - resource = zend_read_property(HttpMessage_Stream_ce, getThis(), ZEND_STRL("stream"), 0, &rv); + resource = zend_read_property(HttpMessage_Stream_ce, PROPERTY_ARG(getThis()), ZEND_STRL("stream"), 0, &rv); if (!IS_STREAM_RESOURCE(resource)) { RETURN_FALSE; } @@ -296,7 +296,7 @@ PHP_METHOD(Stream, write) Z_PARAM_STRING(input, len) ZEND_PARSE_PARAMETERS_END(); - resource = zend_read_property(HttpMessage_Stream_ce, getThis(), ZEND_STRL("stream"), 0, &rv); + resource = zend_read_property(HttpMessage_Stream_ce, PROPERTY_ARG(getThis()), ZEND_STRL("stream"), 0, &rv); if (!IS_STREAM_RESOURCE(resource)) { zend_throw_exception_ex(spl_ce_RuntimeException, 0, "Stream is %s", Z_TYPE_P(resource) == IS_RESOURCE ? "closed" : "detached"); @@ -322,7 +322,7 @@ PHP_METHOD(Stream, isReadable) zval rv, *resource; php_stream *stream; - resource = zend_read_property(HttpMessage_Stream_ce, getThis(), ZEND_STRL("stream"), 0, &rv); + resource = zend_read_property(HttpMessage_Stream_ce, PROPERTY_ARG(getThis()), ZEND_STRL("stream"), 0, &rv); if (!IS_STREAM_RESOURCE(resource)) { RETURN_FALSE; } @@ -348,7 +348,7 @@ PHP_METHOD(Stream, read) return; } - resource = zend_read_property(HttpMessage_Stream_ce, getThis(), ZEND_STRL("stream"), 0, &rv); + resource = zend_read_property(HttpMessage_Stream_ce, PROPERTY_ARG(getThis()), ZEND_STRL("stream"), 0, &rv); if (!IS_STREAM_RESOURCE(resource)) { zend_throw_exception_ex(spl_ce_RuntimeException, 0, "Stream is %s", Z_TYPE_P(resource) == IS_RESOURCE ? "closed" : "detached"); @@ -375,7 +375,7 @@ PHP_METHOD(Stream, getContents) php_stream *stream; zend_string *contents; - resource = zend_read_property(HttpMessage_Stream_ce, getThis(), ZEND_STRL("stream"), 0, &rv); + resource = zend_read_property(HttpMessage_Stream_ce, PROPERTY_ARG(getThis()), ZEND_STRL("stream"), 0, &rv); if (!IS_STREAM_RESOURCE(resource)) { zend_throw_exception_ex(spl_ce_RuntimeException, 0, "Stream is %s", Z_TYPE_P(resource) == IS_RESOURCE ? "closed" : "detached"); @@ -401,7 +401,7 @@ PHP_METHOD(Stream, getMetadata) zval rv, fname, *resource, *zvalue; zend_string *key = NULL; - resource = zend_read_property(HttpMessage_Stream_ce, getThis(), ZEND_STRL("stream"), 0, &rv); + resource = zend_read_property(HttpMessage_Stream_ce, PROPERTY_ARG(getThis()), ZEND_STRL("stream"), 0, &rv); ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_THROW, 0, 1) Z_PARAM_OPTIONAL Z_PARAM_STR(key) diff --git a/tests/Factory/createResponse_err01.phpt b/tests/Factory/createResponse_err01.phpt index 84cbda0..5c741ec 100644 --- a/tests/Factory/createResponse_err01.phpt +++ b/tests/Factory/createResponse_err01.phpt @@ -17,6 +17,6 @@ try { } ?> ---EXPECT-- -Argument 1 passed to HttpMessage\Factory::createResponse() must be of the type int, string given -Argument 2 passed to HttpMessage\Factory::createResponse() must be of the type string, array given +--EXPECTF-- +%sttpMessage\Factory::createResponse()%sint, string given +%sttpMessage\Factory::createResponse()%sstring, array given diff --git a/tests/Factory/createServerRequest_err01.phpt b/tests/Factory/createServerRequest_err01.phpt index a36e8a7..f30c26b 100644 --- a/tests/Factory/createServerRequest_err01.phpt +++ b/tests/Factory/createServerRequest_err01.phpt @@ -29,8 +29,8 @@ try { } ?> ---EXPECT-- +--EXPECTF-- HttpMessage\Factory::createServerRequest() expects at least 2 parameters, 0 given HttpMessage\Factory::createServerRequest() expects at least 2 parameters, 1 given HttpMessage\Factory::createServerRequest() expects parameter 1 to be a string or object that implements Psr\Http\Message\UriInterface, array given -Argument 3 passed to HttpMessage\Factory::createServerRequest() must be of the type array, string given +%sttpMessage\Factory::createServerRequest()%sarray, string given diff --git a/tests/Factory/createStreamFromFile_002.phpt b/tests/Factory/createStreamFromFile_002.phpt index 3fe8934..9feb45f 100644 --- a/tests/Factory/createStreamFromFile_002.phpt +++ b/tests/Factory/createStreamFromFile_002.phpt @@ -17,6 +17,6 @@ try { } ?> ---EXPECT-- -Argument 1 passed to HttpMessage\Factory::createStreamFromFile() must be of the type string, array given -Argument 2 passed to HttpMessage\Factory::createStreamFromFile() must be of the type string, array given +--EXPECTF-- +%sttpMessage\Factory::createStreamFromFile()%sstring, array given +%sttpMessage\Factory::createStreamFromFile()%sstring, array given diff --git a/tests/Factory/createStreamFromFile_err01.phpt b/tests/Factory/createStreamFromFile_err01.phpt index d4099ad..0d8b8f1 100644 --- a/tests/Factory/createStreamFromFile_err01.phpt +++ b/tests/Factory/createStreamFromFile_err01.phpt @@ -17,6 +17,6 @@ try { } ?> ---EXPECT-- -Argument 1 passed to HttpMessage\Factory::createStreamFromFile() must be of the type string, array given -Argument 2 passed to HttpMessage\Factory::createStreamFromFile() must be of the type string, array given \ No newline at end of file +--EXPECTF-- +%sttpMessage\Factory::createStreamFromFile()%sstring, array given +%sttpMessage\Factory::createStreamFromFile()%sstring, array given diff --git a/tests/Factory/createStream_err01.phpt b/tests/Factory/createStream_err01.phpt index 4cff867..be23af2 100644 --- a/tests/Factory/createStream_err01.phpt +++ b/tests/Factory/createStream_err01.phpt @@ -11,5 +11,5 @@ try { } ?> ---EXPECT-- -Argument 1 passed to HttpMessage\Factory::createStream() must be of the type string, array given \ No newline at end of file +--EXPECTF-- +%sttpMessage\Factory::createStream()%sstring, array given diff --git a/tests/Factory/createUploadedFile_err01.phpt b/tests/Factory/createUploadedFile_err01.phpt index 73cced9..0bc72b9 100644 --- a/tests/Factory/createUploadedFile_err01.phpt +++ b/tests/Factory/createUploadedFile_err01.phpt @@ -42,10 +42,10 @@ try { } ?> ---EXPECT-- -Argument 1 passed to HttpMessage\Factory::createUploadedFile() must implement interface Psr\Http\Message\StreamInterface, string given -Argument 1 passed to HttpMessage\Factory::createUploadedFile() must implement interface Psr\Http\Message\StreamInterface, instance of stdClass given -Argument 2 passed to HttpMessage\Factory::createUploadedFile() must be of the type int or null, array given -Argument 3 passed to HttpMessage\Factory::createUploadedFile() must be of the type int, array given -Argument 4 passed to HttpMessage\Factory::createUploadedFile() must be of the type string or null, array given -Argument 5 passed to HttpMessage\Factory::createUploadedFile() must be of the type string or null, array given \ No newline at end of file +--EXPECTF-- +%sttpMessage\Factory::createUploadedFile()%s Psr\Http\Message\StreamInterface, string given +%sttpMessage\Factory::createUploadedFile()%s Psr\Http\Message\StreamInterface,%sstdClass given +%sttpMessage\Factory::createUploadedFile()%s, array given +%sttpMessage\Factory::createUploadedFile()%sint, array given +%sttpMessage\Factory::createUploadedFile()%s, array given +%sttpMessage\Factory::createUploadedFile()%s, array given diff --git a/tests/Message/body_err01.phpt b/tests/Message/body_err01.phpt index dd0c826..571fb38 100644 --- a/tests/Message/body_err01.phpt +++ b/tests/Message/body_err01.phpt @@ -18,6 +18,6 @@ try { } ?> ---EXPECT-- -Argument 1 passed to HttpMessage\Message::withBody() must implement interface Psr\Http\Message\StreamInterface, resource given +--EXPECTF-- +%sttpMessage\Message::withBody()%s Psr\Http\Message\StreamInterface, resource given HttpMessage\Message::withBody() expects exactly 1 parameter, 0 given diff --git a/tests/Message/headers_err01.phpt b/tests/Message/headers_err01.phpt index f1accf9..84332bc 100644 --- a/tests/Message/headers_err01.phpt +++ b/tests/Message/headers_err01.phpt @@ -23,7 +23,7 @@ try { } ?> ---EXPECT-- -HttpMessage\Message::withHeader() expects parameter 2 to be string, array given +--EXPECTF-- +HttpMessage\Message::withHeader()%sstring, array given HttpMessage\Message::withHeader() expects exactly 2 parameters, 1 given -HttpMessage\Message::withHeader() expects parameter 1 to be string, array given +HttpMessage\Message::withHeader()%sstring, array given diff --git a/tests/Message/headers_err02.phpt b/tests/Message/headers_err02.phpt index ed7a57a..607fa13 100644 --- a/tests/Message/headers_err02.phpt +++ b/tests/Message/headers_err02.phpt @@ -23,7 +23,7 @@ try { } ?> ---EXPECT-- -HttpMessage\Message::withAddedHeader() expects parameter 2 to be string, array given +--EXPECTF-- +HttpMessage\Message::withAddedHeader()%sstring, array given HttpMessage\Message::withAddedHeader() expects exactly 2 parameters, 1 given -HttpMessage\Message::withAddedHeader() expects parameter 1 to be string, array given +HttpMessage\Message::withAddedHeader()%sstring, array given diff --git a/tests/Message/headers_err03.phpt b/tests/Message/headers_err03.phpt index 604aae1..ed65c5a 100644 --- a/tests/Message/headers_err03.phpt +++ b/tests/Message/headers_err03.phpt @@ -17,6 +17,6 @@ try { } ?> ---EXPECT-- -HttpMessage\Message::withoutHeader() expects parameter 1 to be string, array given -HttpMessage\Message::withoutHeader() expects exactly 1 parameter, 0 given \ No newline at end of file +--EXPECTF-- +HttpMessage\Message::withoutHeader()%sstring, array given +HttpMessage\Message::withoutHeader() expects exactly 1 parameter, 0 given diff --git a/tests/Message/headers_err04.phpt b/tests/Message/headers_err04.phpt index 85b1a6d..2be1ac0 100644 --- a/tests/Message/headers_err04.phpt +++ b/tests/Message/headers_err04.phpt @@ -17,6 +17,6 @@ try { } ?> ---EXPECT-- -HttpMessage\Message::getHeader() expects parameter 1 to be string, array given -HttpMessage\Message::getHeader() expects exactly 1 parameter, 0 given \ No newline at end of file +--EXPECTF-- +HttpMessage\Message::getHeader()%sstring, array given +HttpMessage\Message::getHeader() expects exactly 1 parameter, 0 given diff --git a/tests/Message/headers_err05.phpt b/tests/Message/headers_err05.phpt index 62a28c9..ab2b43f 100644 --- a/tests/Message/headers_err05.phpt +++ b/tests/Message/headers_err05.phpt @@ -17,6 +17,6 @@ try { } ?> ---EXPECT-- -HttpMessage\Message::getHeaderLine() expects parameter 1 to be string, array given -HttpMessage\Message::getHeaderLine() expects exactly 1 parameter, 0 given \ No newline at end of file +--EXPECTF-- +HttpMessage\Message::getHeaderLine()%sstring, array given +HttpMessage\Message::getHeaderLine() expects exactly 1 parameter, 0 given diff --git a/tests/Message/protocolVersion_err01.phpt b/tests/Message/protocolVersion_err01.phpt index d22a35b..6401d49 100644 --- a/tests/Message/protocolVersion_err01.phpt +++ b/tests/Message/protocolVersion_err01.phpt @@ -16,6 +16,6 @@ try { echo $e->getMessage(), "\n"; } ?> ---EXPECT-- +--EXPECTF-- HttpMessage\Message::withProtocolVersion() expects exactly 1 parameter, 0 given -HttpMessage\Message::withProtocolVersion() expects parameter 1 to be string, array given \ No newline at end of file +HttpMessage\Message::withProtocolVersion()%sstring, array given diff --git a/tests/Request/method_err01.phpt b/tests/Request/method_err01.phpt index e532071..4396100 100644 --- a/tests/Request/method_err01.phpt +++ b/tests/Request/method_err01.phpt @@ -17,6 +17,6 @@ try { } ?> ---EXPECT-- +--EXPECTF-- HttpMessage\Request::withMethod() expects exactly 1 parameter, 0 given -HttpMessage\Request::withMethod() expects parameter 1 to be string, array given +HttpMessage\Request::withMethod()%sstring, array given diff --git a/tests/Request/requestTarget_err01.phpt b/tests/Request/requestTarget_err01.phpt index ff11a06..2d93d63 100644 --- a/tests/Request/requestTarget_err01.phpt +++ b/tests/Request/requestTarget_err01.phpt @@ -17,6 +17,6 @@ try { } ?> ---EXPECT-- +--EXPECTF-- HttpMessage\Request::withRequestTarget() expects exactly 1 parameter, 0 given -HttpMessage\Request::withRequestTarget() expects parameter 1 to be string, array given +HttpMessage\Request::withRequestTarget()%sstring, array given diff --git a/tests/Request/uri_err01.phpt b/tests/Request/uri_err01.phpt index f6ba3a7..697e754 100644 --- a/tests/Request/uri_err01.phpt +++ b/tests/Request/uri_err01.phpt @@ -17,6 +17,6 @@ try { } ?> ---EXPECT-- +--EXPECTF-- HttpMessage\Request::withUri() expects exactly 1 parameter, 0 given -Argument 1 passed to HttpMessage\Request::withUri() must implement interface Psr\Http\Message\UriInterface, string given +%sttpMessage\Request::withUri()%sPsr\Http\Message\UriInterface, string given diff --git a/tests/Response/status_err01.phpt b/tests/Response/status_err01.phpt index 9c028ea..5111e7d 100644 --- a/tests/Response/status_err01.phpt +++ b/tests/Response/status_err01.phpt @@ -23,7 +23,7 @@ try { } ?> ---EXPECT-- +--EXPECTF-- HttpMessage\Response::withStatus() expects at least 1 parameter, 0 given -HttpMessage\Response::withStatus() expects parameter 1 to be int, string given -HttpMessage\Response::withStatus() expects parameter 2 to be string, array given \ No newline at end of file +HttpMessage\Response::withStatus()%sint, string given +HttpMessage\Response::withStatus()%sstring, array given diff --git a/tests/ServerRequest/__construct_err01.phpt b/tests/ServerRequest/__construct_err01.phpt index 358d824..586d505 100644 --- a/tests/ServerRequest/__construct_err01.phpt +++ b/tests/ServerRequest/__construct_err01.phpt @@ -40,10 +40,10 @@ try { } ?> ---EXPECT-- -Argument 1 passed to HttpMessage\ServerRequest::__construct() must be of the type array, string given -Argument 2 passed to HttpMessage\ServerRequest::__construct() must be of the type array, string given -Argument 3 passed to HttpMessage\ServerRequest::__construct() must be of the type array, string given -Argument 3 passed to HttpMessage\ServerRequest::__construct() must be of the type array, string given -Argument 4 passed to HttpMessage\ServerRequest::__construct() must be of the type array, string given -Argument 5 passed to HttpMessage\ServerRequest::__construct() must be of the type array, string given +--EXPECTF-- +%sttpMessage\ServerRequest::__construct()%sarray, string given +%sttpMessage\ServerRequest::__construct()%sarray, string given +%sttpMessage\ServerRequest::__construct()%sarray, string given +%sttpMessage\ServerRequest::__construct()%sarray, string given +%sttpMessage\ServerRequest::__construct()%sarray, string given +%sttpMessage\ServerRequest::__construct()%sarray, string given diff --git a/tests/ServerRequest/attributes_err01.phpt b/tests/ServerRequest/attributes_err01.phpt index 5299da3..b679674 100644 --- a/tests/ServerRequest/attributes_err01.phpt +++ b/tests/ServerRequest/attributes_err01.phpt @@ -17,6 +17,6 @@ try { } ?> ---EXPECT-- +--EXPECTF-- HttpMessage\ServerRequest::withAttribute() expects exactly 2 parameters, 1 given -HttpMessage\ServerRequest::withAttribute() expects parameter 1 to be string, array given \ No newline at end of file +HttpMessage\ServerRequest::withAttribute()%s string, array given diff --git a/tests/ServerRequest/cookieParams_err01.phpt b/tests/ServerRequest/cookieParams_err01.phpt index 55c1475..f1d4071 100644 --- a/tests/ServerRequest/cookieParams_err01.phpt +++ b/tests/ServerRequest/cookieParams_err01.phpt @@ -17,6 +17,6 @@ try { } ?> ---EXPECT-- +--EXPECTF-- HttpMessage\ServerRequest::withCookieParams() expects exactly 1 parameter, 0 given -Argument 1 passed to HttpMessage\ServerRequest::withCookieParams() must be of the type array, string given \ No newline at end of file +%sttpMessage\ServerRequest::withCookieParams()%s array, string given diff --git a/tests/ServerRequest/parsedBody_err01.phpt b/tests/ServerRequest/parsedBody_err01.phpt index b148260..ec2a019 100644 --- a/tests/ServerRequest/parsedBody_err01.phpt +++ b/tests/ServerRequest/parsedBody_err01.phpt @@ -17,6 +17,6 @@ try { } ?> ---EXPECT-- +--EXPECTF-- HttpMessage\ServerRequest::withQueryParams() expects exactly 1 parameter, 0 given -HttpMessage\ServerRequest::withParsedBody() expects parameter 1 to be array, string given \ No newline at end of file +HttpMessage\ServerRequest::withParsedBody()%sarray, string given diff --git a/tests/ServerRequest/queryParams_err01.phpt b/tests/ServerRequest/queryParams_err01.phpt index d66f8ca..593bdf7 100644 --- a/tests/ServerRequest/queryParams_err01.phpt +++ b/tests/ServerRequest/queryParams_err01.phpt @@ -17,6 +17,6 @@ try { } ?> ---EXPECT-- +--EXPECTF-- HttpMessage\ServerRequest::withQueryParams() expects exactly 1 parameter, 0 given -Argument 1 passed to HttpMessage\ServerRequest::withQueryParams() must be of the type array, string given \ No newline at end of file +%sttpMessage\ServerRequest::withQueryParams()%s array, string given diff --git a/tests/Stream/read_err02.phpt b/tests/Stream/read_err02.phpt index 3088a37..3a32dee 100644 --- a/tests/Stream/read_err02.phpt +++ b/tests/Stream/read_err02.phpt @@ -18,5 +18,5 @@ try { } ?> --EXPECTF-- -HttpMessage\Stream::read() expects parameter 1 to be int, string given +HttpMessage\Stream::read()%s int, string given Length parameter must be equal or greater than 0 diff --git a/tests/Stream/seek_err02.phpt b/tests/Stream/seek_err02.phpt index 70f7de1..8ab5755 100644 --- a/tests/Stream/seek_err02.phpt +++ b/tests/Stream/seek_err02.phpt @@ -18,5 +18,5 @@ try { } ?> --EXPECTF-- -HttpMessage\Stream::seek() expects parameter 1 to be int, string given -HttpMessage\Stream::seek() expects parameter 2 to be int, string given +HttpMessage\Stream::seek()%s int, string given +HttpMessage\Stream::seek()%s int, string given diff --git a/tests/Stream/write_err02.phpt b/tests/Stream/write_err02.phpt index 49bca61..933b338 100644 --- a/tests/Stream/write_err02.phpt +++ b/tests/Stream/write_err02.phpt @@ -11,5 +11,5 @@ try { echo $e->getMessage(), "\n"; } ?> ---EXPECT-- -HttpMessage\Stream::write() expects parameter 1 to be string, array given \ No newline at end of file +--EXPECTF-- +HttpMessage\Stream::write()%s string, array given diff --git a/tests/UploadedFile/__construct_err01.phpt b/tests/UploadedFile/__construct_err01.phpt index 6095895..51cf776 100644 --- a/tests/UploadedFile/__construct_err01.phpt +++ b/tests/UploadedFile/__construct_err01.phpt @@ -41,10 +41,10 @@ try { } ?> ---EXPECT-- +--EXPECTF-- HttpMessage\UploadedFile::__construct() expects parameter 1 to be a string or object that implements Psr\Http\Message\StreamInterface, array given -HttpMessage\UploadedFile::__construct() expects parameter 1 to be a string or object that implements Psr\Http\Message\StreamInterface, object given -Argument 2 passed to HttpMessage\UploadedFile::__construct() must be of the type int or null, array given -Argument 3 passed to HttpMessage\UploadedFile::__construct() must be of the type int, array given -Argument 4 passed to HttpMessage\UploadedFile::__construct() must be of the type string or null, array given -Argument 5 passed to HttpMessage\UploadedFile::__construct() must be of the type string or null, array given \ No newline at end of file +HttpMessage\UploadedFile::__construct() expects parameter 1 to be a string or object that implements Psr\Http\Message\StreamInterface, %s given +%sttpMessage\UploadedFile::__construct()%s, array given +%sttpMessage\UploadedFile::__construct()%s, array given +%sttpMessage\UploadedFile::__construct()%s, array given +%sttpMessage\UploadedFile::__construct()%s, array given diff --git a/tests/UploadedFile/moveTo_err03.phpt b/tests/UploadedFile/moveTo_err03.phpt index fb12acf..46d1ab7 100644 --- a/tests/UploadedFile/moveTo_err03.phpt +++ b/tests/UploadedFile/moveTo_err03.phpt @@ -20,5 +20,5 @@ if (file_exists(sys_get_temp_dir() . '/uploadedfile') { } ?> --EXPECTF-- -Warning: HttpMessage\UploadedFile::moveTo(%s/nosuchdir/movedfile): failed to open stream: No such file or directory in %smoveTo_err03.php on line %d -Failed to move uploaded file '%s/uploadedfile' to '%s/nosuchdir/movedfile' \ No newline at end of file +Warning: HttpMessage\UploadedFile::moveTo(%s/nosuchdir/movedfile): %sailed to open stream: No such file or directory in %smoveTo_err03.php on line %d +Failed to move uploaded file '%s/uploadedfile' to '%s/nosuchdir/movedfile' diff --git a/tests/UploadedFile/moveTo_err05.phpt b/tests/UploadedFile/moveTo_err05.phpt index 12ea517..f4d5807 100644 --- a/tests/UploadedFile/moveTo_err05.phpt +++ b/tests/UploadedFile/moveTo_err05.phpt @@ -18,5 +18,5 @@ if (file_exists(sys_get_temp_dir() . '/movedfile') { } ?> --EXPECTF-- -Warning: HttpMessage\UploadedFile::moveTo(%s): failed to open stream: No such file or directory in %s on line %d +Warning: HttpMessage\UploadedFile::moveTo(%s): %sailed to open stream: No such file or directory in %s on line %d Failed to move uploaded file '%s/UploadedFile/not/exist' to '%s/movedfile' diff --git a/tests/Uri/__construct_err01.phpt b/tests/Uri/__construct_err01.phpt index 240e680..0980baa 100644 --- a/tests/Uri/__construct_err01.phpt +++ b/tests/Uri/__construct_err01.phpt @@ -8,5 +8,5 @@ try { echo $e->getMessage(), "\n"; } ?> ---EXPECT-- -Argument 1 passed to HttpMessage\Uri::__construct() must be of the type string, array given +--EXPECTF-- +%sttpMessage\Uri::__construct()%s string, array given diff --git a/tests/Uri/fragment_err01.phpt b/tests/Uri/fragment_err01.phpt index d6f4503..a088cac 100644 --- a/tests/Uri/fragment_err01.phpt +++ b/tests/Uri/fragment_err01.phpt @@ -8,5 +8,5 @@ try { echo $e->getMessage(), "\n"; } ?> ---EXPECT-- -HttpMessage\Uri::withFragment() expects parameter 1 to be string, array given +--EXPECTF-- +HttpMessage\Uri::withFragment()%s string, array given diff --git a/tests/Uri/host_error.phpt b/tests/Uri/host_error.phpt index b0f660d..d0e1ceb 100644 --- a/tests/Uri/host_error.phpt +++ b/tests/Uri/host_error.phpt @@ -14,6 +14,6 @@ try { echo $e->getMessage(), "\n"; } ?> ---EXPECT-- -HttpMessage\Uri::withHost() expects parameter 1 to be string, array given +--EXPECTF-- +HttpMessage\Uri::withHost()%s, array given HttpMessage\Uri::withHost() expects exactly 1 parameter, 0 given diff --git a/tests/Uri/path_err01.phpt b/tests/Uri/path_err01.phpt index a8c0c55..b44e75a 100644 --- a/tests/Uri/path_err01.phpt +++ b/tests/Uri/path_err01.phpt @@ -8,5 +8,5 @@ try { echo $e->getMessage(), "\n"; } ?> ---EXPECT-- -HttpMessage\Uri::withPath() expects parameter 1 to be string, array given +--EXPECTF-- +HttpMessage\Uri::withPath()%s string, array given diff --git a/tests/Uri/port_err01.phpt b/tests/Uri/port_err01.phpt index 68aa908..1dd9dc0 100644 --- a/tests/Uri/port_err01.phpt +++ b/tests/Uri/port_err01.phpt @@ -9,4 +9,4 @@ try { } ?> --EXPECTF-- -HttpMessage\Uri::withPort() expects parameter 1 to be int, array given +HttpMessage\Uri::withPort()%sint, array given diff --git a/tests/Uri/query_err01.phpt b/tests/Uri/query_err01.phpt index b1e084d..dc6051e 100644 --- a/tests/Uri/query_err01.phpt +++ b/tests/Uri/query_err01.phpt @@ -8,5 +8,5 @@ try { echo $e->getMessage(), "\n"; } ?> ---EXPECT-- -HttpMessage\Uri::withQuery() expects parameter 1 to be string, array given +--EXPECTF-- +HttpMessage\Uri::withQuery()%s string, array given diff --git a/tests/Uri/scheme_err01.phpt b/tests/Uri/scheme_err01.phpt index 8530982..2df465d 100644 --- a/tests/Uri/scheme_err01.phpt +++ b/tests/Uri/scheme_err01.phpt @@ -8,5 +8,5 @@ try { echo $e->getMessage(), "\n"; } ?> ---EXPECT-- -HttpMessage\Uri::withScheme() expects parameter 1 to be string, array given +--EXPECTF-- +HttpMessage\Uri::withScheme()%s string, array given diff --git a/tests/Uri/userInfo_err01.phpt b/tests/Uri/userInfo_err01.phpt index ca4499c..6be1486 100644 --- a/tests/Uri/userInfo_err01.phpt +++ b/tests/Uri/userInfo_err01.phpt @@ -8,5 +8,5 @@ try { echo $e->getMessage(), "\n"; } ?> ---EXPECT-- -HttpMessage\Uri::withUserInfo() expects parameter 1 to be string, array given +--EXPECTF-- +HttpMessage\Uri::withUserInfo()%s string, array given diff --git a/uploaded_file.c b/uploaded_file.c index 0b2b60b..0695c63 100644 --- a/uploaded_file.c +++ b/uploaded_file.c @@ -63,7 +63,7 @@ int assert_file_available(zval *file, zval *stream, zval *moved) } else { // Can be any StreamInterface object, doesn't need to be Stream from this lib. ZVAL_STRINGL(&arg1, "uri", 3); - zend_call_method_with_1_params(stream, NULL, NULL, "getMetadata", &stream_file, &arg1); + zend_call_method_with_1_params(PROPERTY_ARG(stream), NULL, NULL, "getMetadata", &stream_file, &arg1); filename = Z_STRVAL(stream_file); STR_CLOSE(filename, Z_STRLEN(stream_file)); } @@ -144,7 +144,7 @@ int move_uploaded_stream(zval *stream, char *new_path, size_t new_path_len) int ret; // Can be any StreamInterface object, doesn't need to be Stream from this lib. - zend_call_method_with_0_params(stream, NULL, NULL, "detach", &resource); + zend_call_method_with_0_params(PROPERTY_ARG(stream), NULL, NULL, "detach", &resource); source = (php_stream*)zend_fetch_resource2_ex(&resource, "stream", php_file_le_stream(), php_file_le_pstream()); STR_CLOSE(new_path, new_path_len); @@ -182,37 +182,37 @@ void construct_uploaded_file( if (error == 0 && stream != NULL) { // Must be verified it's a StreamInterface object before passing it to this function. // Can be any StreamInterface object, doesn't need to be Stream from this lib. - zend_call_method_with_0_params(stream, NULL, NULL, "isReadable", &zreadable); + zend_call_method_with_0_params(PROPERTY_ARG(stream), NULL, NULL, "isReadable", &zreadable); if (UNEXPECTED(Z_TYPE(zreadable) != IS_TRUE)) { zend_throw_exception( spl_ce_InvalidArgumentException, "Stream provided for uploaded file is not readable", 0 ); } - zend_update_property(HttpMessage_UploadedFile_ce, object, ZEND_STRL("stream"), stream); + zend_update_property(HttpMessage_UploadedFile_ce, PROPERTY_ARG(object), ZEND_STRL("stream"), stream); } else if (error == 0 && file != NULL) { - zend_update_property_str(HttpMessage_UploadedFile_ce, object, ZEND_STRL("file"), file); + zend_update_property_str(HttpMessage_UploadedFile_ce, PROPERTY_ARG(object), ZEND_STRL("file"), file); } if (clientFilename != NULL) { - zend_update_property_str(HttpMessage_UploadedFile_ce, object, ZEND_STRL("clientFilename"), clientFilename); + zend_update_property_str(HttpMessage_UploadedFile_ce, PROPERTY_ARG(object), ZEND_STRL("clientFilename"), clientFilename); } if (clientMediaType != NULL) { - zend_update_property_str(HttpMessage_UploadedFile_ce, object, ZEND_STRL("clientMediaType"), clientMediaType); + zend_update_property_str(HttpMessage_UploadedFile_ce, PROPERTY_ARG(object), ZEND_STRL("clientMediaType"), clientMediaType); } if (size > 0) { - zend_update_property_long(HttpMessage_UploadedFile_ce, object, ZEND_STRL("size"), size); + zend_update_property_long(HttpMessage_UploadedFile_ce, PROPERTY_ARG(object), ZEND_STRL("size"), size); } if (error < 0 || error > 8) { zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "Invalid error code %ld", error); } - zend_update_property_long(HttpMessage_UploadedFile_ce, object, ZEND_STRL("error"), error); + zend_update_property_long(HttpMessage_UploadedFile_ce, PROPERTY_ARG(object), ZEND_STRL("error"), error); if (checkUploaded < 0) { checkUploaded = SG(rfc1867_uploaded_files) != NULL; } - zend_update_property_bool(HttpMessage_UploadedFile_ce, object, ZEND_STRL("checkUploaded"), checkUploaded); + zend_update_property_bool(HttpMessage_UploadedFile_ce, PROPERTY_ARG(object), ZEND_STRL("checkUploaded"), checkUploaded); } void create_uploaded_file(zval *uploaded_file, zval *tmp_name, zval *size, zval *error, zval *name, zval *type) @@ -360,9 +360,9 @@ PHP_METHOD(UploadedFile, getStream) { zval rv, *stream, *file, *moved, mode; - file = zend_read_property(HttpMessage_UploadedFile_ce, getThis(), ZEND_STRL("file"), 0, &rv); - stream = zend_read_property(HttpMessage_UploadedFile_ce, getThis(), ZEND_STRL("stream"), 0, &rv); - moved = zend_read_property(HttpMessage_UploadedFile_ce, getThis(), ZEND_STRL("moved"), 0, &rv); + file = zend_read_property(HttpMessage_UploadedFile_ce, PROPERTY_ARG(getThis()), ZEND_STRL("file"), 0, &rv); + stream = zend_read_property(HttpMessage_UploadedFile_ce, PROPERTY_ARG(getThis()), ZEND_STRL("stream"), 0, &rv); + moved = zend_read_property(HttpMessage_UploadedFile_ce, PROPERTY_ARG(getThis()), ZEND_STRL("moved"), 0, &rv); if (assert_file_available(file, stream, moved) == FAILURE) { return; @@ -388,10 +388,10 @@ PHP_METHOD(UploadedFile, moveTo) Z_PARAM_PATH(new_path, new_path_len) ZEND_PARSE_PARAMETERS_END(); - file = zend_read_property(HttpMessage_UploadedFile_ce, getThis(), ZEND_STRL("file"), 0, &rv); - stream = zend_read_property(HttpMessage_UploadedFile_ce, getThis(), ZEND_STRL("stream"), 0, &rv); - moved = zend_read_property(HttpMessage_UploadedFile_ce, getThis(), ZEND_STRL("moved"), 0, &rv); - checkUploaded = zend_read_property(HttpMessage_UploadedFile_ce, getThis(), ZEND_STRL("checkUploaded"), 0, &rv); + file = zend_read_property(HttpMessage_UploadedFile_ce, PROPERTY_ARG(getThis()), ZEND_STRL("file"), 0, &rv); + stream = zend_read_property(HttpMessage_UploadedFile_ce, PROPERTY_ARG(getThis()), ZEND_STRL("stream"), 0, &rv); + moved = zend_read_property(HttpMessage_UploadedFile_ce, PROPERTY_ARG(getThis()), ZEND_STRL("moved"), 0, &rv); + checkUploaded = zend_read_property(HttpMessage_UploadedFile_ce, PROPERTY_ARG(getThis()), ZEND_STRL("checkUploaded"), 0, &rv); if ( assert_file_available(file, stream, moved) == FAILURE || @@ -413,7 +413,7 @@ PHP_METHOD(UploadedFile, getSize) { zval rv, *value; - value = zend_read_property(HttpMessage_UploadedFile_ce, getThis(), ZEND_STRL("size"), 0, &rv); + value = zend_read_property(HttpMessage_UploadedFile_ce, PROPERTY_ARG(getThis()), ZEND_STRL("size"), 0, &rv); RETURN_ZVAL(value, 1, 0); } @@ -422,7 +422,7 @@ PHP_METHOD(UploadedFile, getError) { zval rv, *value; - value = zend_read_property(HttpMessage_UploadedFile_ce, getThis(), ZEND_STRL("error"), 0, &rv); + value = zend_read_property(HttpMessage_UploadedFile_ce, PROPERTY_ARG(getThis()), ZEND_STRL("error"), 0, &rv); RETURN_ZVAL(value, 1, 0); } @@ -431,7 +431,7 @@ PHP_METHOD(UploadedFile, getClientFilename) { zval rv, *value; - value = zend_read_property(HttpMessage_UploadedFile_ce, getThis(), ZEND_STRL("clientFilename"), 0, &rv); + value = zend_read_property(HttpMessage_UploadedFile_ce, PROPERTY_ARG(getThis()), ZEND_STRL("clientFilename"), 0, &rv); RETURN_ZVAL(value, 1, 0); } @@ -440,7 +440,7 @@ PHP_METHOD(UploadedFile, getClientMediaType) { zval rv, *value; - value = zend_read_property(HttpMessage_UploadedFile_ce, getThis(), ZEND_STRL("clientMediaType"), 0, &rv); + value = zend_read_property(HttpMessage_UploadedFile_ce, PROPERTY_ARG(getThis()), ZEND_STRL("clientMediaType"), 0, &rv); RETURN_ZVAL(value, 1, 0); } diff --git a/uri.c b/uri.c index a0ee490..1f5b4c6 100644 --- a/uri.c +++ b/uri.c @@ -53,7 +53,7 @@ void uri_set_userinfo(zval *uri, char *user, size_t user_len, char *pass, size_t } if (pass_len == 0) { - zend_update_property_stringl(HttpMessage_Uri_ce, uri, ZEND_STRL("userInfo"), user, user_len); + zend_update_property_stringl(HttpMessage_Uri_ce, PROPERTY_ARG(uri), ZEND_STRL("userInfo"), user, user_len); } else { userinfo = emalloc(user_len + pass_len + 2); if (UNEXPECTED(userinfo == NULL)) return; // Memory issue @@ -62,7 +62,7 @@ void uri_set_userinfo(zval *uri, char *user, size_t user_len, char *pass, size_t pass[pass_len] = '\0'; sprintf(userinfo, "%s:%s", user, pass); - zend_update_property_stringl(HttpMessage_Uri_ce, uri, ZEND_STRL("userInfo"), userinfo, user_len + pass_len + 1); + zend_update_property_stringl(HttpMessage_Uri_ce, PROPERTY_ARG(uri), ZEND_STRL("userInfo"), userinfo, user_len + pass_len + 1); efree(userinfo); } @@ -100,7 +100,7 @@ PHP_METHOD(Uri, __construct) SET_URI_PROPERTY(HttpMessage_Uri_ce, "fragment", info->fragment); if (info->port > 0) { - zend_update_property_long(HttpMessage_Uri_ce, getThis(), ZEND_STRL("port"), info->port); + zend_update_property_long(HttpMessage_Uri_ce, PROPERTY_ARG(getThis()), ZEND_STRL("port"), info->port); } #if PHP_VERSION_ID < 70300 @@ -124,13 +124,13 @@ PHP_METHOD(Uri, __toString) char *path_ptr; size_t path_len = 0; - scheme = zend_read_property(HttpMessage_Uri_ce, getThis(), ZEND_STRL("scheme"), 0, &rv); - userinfo = zend_read_property(HttpMessage_Uri_ce, getThis(), ZEND_STRL("userInfo"), 0, &rv); - host = zend_read_property(HttpMessage_Uri_ce, getThis(), ZEND_STRL("host"), 0, &rv); - port = zend_read_property(HttpMessage_Uri_ce, getThis(), ZEND_STRL("port"), 0, &rv); - path = zend_read_property(HttpMessage_Uri_ce, getThis(), ZEND_STRL("path"), 0, &rv); - query = zend_read_property(HttpMessage_Uri_ce, getThis(), ZEND_STRL("query"), 0, &rv); - fragment = zend_read_property(HttpMessage_Uri_ce, getThis(), ZEND_STRL("fragment"), 0, &rv); + scheme = zend_read_property(HttpMessage_Uri_ce, PROPERTY_ARG(getThis()), ZEND_STRL("scheme"), 0, &rv); + userinfo = zend_read_property(HttpMessage_Uri_ce, PROPERTY_ARG(getThis()), ZEND_STRL("userInfo"), 0, &rv); + host = zend_read_property(HttpMessage_Uri_ce, PROPERTY_ARG(getThis()), ZEND_STRL("host"), 0, &rv); + port = zend_read_property(HttpMessage_Uri_ce, PROPERTY_ARG(getThis()), ZEND_STRL("port"), 0, &rv); + path = zend_read_property(HttpMessage_Uri_ce, PROPERTY_ARG(getThis()), ZEND_STRL("path"), 0, &rv); + query = zend_read_property(HttpMessage_Uri_ce, PROPERTY_ARG(getThis()), ZEND_STRL("query"), 0, &rv); + fragment = zend_read_property(HttpMessage_Uri_ce, PROPERTY_ARG(getThis()), ZEND_STRL("fragment"), 0, &rv); smart_str_alloc(&buf, 0, 0); @@ -194,7 +194,7 @@ PHP_METHOD(Uri, getScheme) { zval rv, *value; - value = zend_read_property(HttpMessage_Uri_ce, getThis(), ZEND_STRL("scheme"), 0, &rv); + value = zend_read_property(HttpMessage_Uri_ce, PROPERTY_ARG(getThis()), ZEND_STRL("scheme"), 0, &rv); RETURN_ZVAL(value, 1, 0); } @@ -207,9 +207,9 @@ PHP_METHOD(Uri, withScheme) Z_PARAM_STR(value) ZEND_PARSE_PARAMETERS_END(); - ZVAL_OBJ(return_value, zend_objects_clone_obj(getThis())); + ZVAL_OBJ(return_value, zend_objects_clone_obj(PROPERTY_ARG(getThis()))); - zend_update_property_str(HttpMessage_Uri_ce, return_value, ZEND_STRL("scheme"), value); + zend_update_property_str(HttpMessage_Uri_ce, PROPERTY_ARG(return_value), ZEND_STRL("scheme"), value); } @@ -220,9 +220,9 @@ PHP_METHOD(Uri, getAuthority) zval rv, *userinfo, *host, *port; smart_str buf = {0}; - userinfo = zend_read_property(HttpMessage_Uri_ce, getThis(), ZEND_STRL("userInfo"), 0, &rv); - host = zend_read_property(HttpMessage_Uri_ce, getThis(), ZEND_STRL("host"), 0, &rv); - port = zend_read_property(HttpMessage_Uri_ce, getThis(), ZEND_STRL("port"), 0, &rv); + userinfo = zend_read_property(HttpMessage_Uri_ce, PROPERTY_ARG(getThis()), ZEND_STRL("userInfo"), 0, &rv); + host = zend_read_property(HttpMessage_Uri_ce, PROPERTY_ARG(getThis()), ZEND_STRL("host"), 0, &rv); + port = zend_read_property(HttpMessage_Uri_ce, PROPERTY_ARG(getThis()), ZEND_STRL("port"), 0, &rv); if (Z_STRLEN_P(host) == 0) { RETURN_EMPTY_STRING(); @@ -251,7 +251,7 @@ PHP_METHOD(Uri, getUserInfo) { zval rv, *value; - value = zend_read_property(HttpMessage_Uri_ce, getThis(), ZEND_STRL("userInfo"), 0, &rv); + value = zend_read_property(HttpMessage_Uri_ce, PROPERTY_ARG(getThis()), ZEND_STRL("userInfo"), 0, &rv); RETURN_ZVAL(value, 1, 0); } @@ -264,9 +264,9 @@ PHP_METHOD(Uri, withUserInfo) Z_PARAM_STR(value) ZEND_PARSE_PARAMETERS_END(); - ZVAL_OBJ(return_value, zend_objects_clone_obj(getThis())); + ZVAL_OBJ(return_value, zend_objects_clone_obj(PROPERTY_ARG(getThis()))); - zend_update_property_str(HttpMessage_Uri_ce, return_value, ZEND_STRL("userInfo"), value); + zend_update_property_str(HttpMessage_Uri_ce, PROPERTY_ARG(return_value), ZEND_STRL("userInfo"), value); } @@ -276,7 +276,7 @@ PHP_METHOD(Uri, getHost) { zval rv, *value; - value = zend_read_property(HttpMessage_Uri_ce, getThis(), ZEND_STRL("host"), 0, &rv); + value = zend_read_property(HttpMessage_Uri_ce, PROPERTY_ARG(getThis()), ZEND_STRL("host"), 0, &rv); RETURN_ZVAL(value, 1, 0); } @@ -289,9 +289,9 @@ PHP_METHOD(Uri, withHost) Z_PARAM_STR(value) ZEND_PARSE_PARAMETERS_END(); - ZVAL_OBJ(return_value, zend_objects_clone_obj(getThis())); + ZVAL_OBJ(return_value, zend_objects_clone_obj(PROPERTY_ARG(getThis()))); - zend_update_property_str(HttpMessage_Uri_ce, return_value, ZEND_STRL("host"), value); + zend_update_property_str(HttpMessage_Uri_ce, PROPERTY_ARG(return_value), ZEND_STRL("host"), value); } @@ -301,7 +301,7 @@ PHP_METHOD(Uri, getPort) { zval rv, *value; - value = zend_read_property(HttpMessage_Uri_ce, getThis(), ZEND_STRL("port"), 0, &rv); + value = zend_read_property(HttpMessage_Uri_ce, PROPERTY_ARG(getThis()), ZEND_STRL("port"), 0, &rv); RETURN_ZVAL(value, 1, 0); } @@ -315,12 +315,12 @@ PHP_METHOD(Uri, withPort) Z_PARAM_LONG_EX(value, value_is_null,1, 0) ZEND_PARSE_PARAMETERS_END(); - ZVAL_OBJ(return_value, zend_objects_clone_obj(getThis())); + ZVAL_OBJ(return_value, zend_objects_clone_obj(PROPERTY_ARG(getThis()))); if (!value_is_null) { - zend_update_property_long(HttpMessage_Uri_ce, return_value, ZEND_STRL("port"), value); + zend_update_property_long(HttpMessage_Uri_ce, PROPERTY_ARG(return_value), ZEND_STRL("port"), value); } else { - zend_update_property_null(HttpMessage_Uri_ce, return_value, ZEND_STRL("port")); + zend_update_property_null(HttpMessage_Uri_ce, PROPERTY_ARG(return_value), ZEND_STRL("port")); } } @@ -331,7 +331,7 @@ PHP_METHOD(Uri, getPath) { zval rv, *value; - value = zend_read_property(HttpMessage_Uri_ce, getThis(), ZEND_STRL("path"), 0, &rv); + value = zend_read_property(HttpMessage_Uri_ce, PROPERTY_ARG(getThis()), ZEND_STRL("path"), 0, &rv); RETURN_ZVAL(value, 1, 0); } @@ -344,9 +344,9 @@ PHP_METHOD(Uri, withPath) Z_PARAM_STR(value) ZEND_PARSE_PARAMETERS_END(); - ZVAL_OBJ(return_value, zend_objects_clone_obj(getThis())); + ZVAL_OBJ(return_value, zend_objects_clone_obj(PROPERTY_ARG(getThis()))); - zend_update_property_str(HttpMessage_Uri_ce, return_value, ZEND_STRL("path"), value); + zend_update_property_str(HttpMessage_Uri_ce, PROPERTY_ARG(return_value), ZEND_STRL("path"), value); } @@ -356,7 +356,7 @@ PHP_METHOD(Uri, getQuery) { zval rv, *value; - value = zend_read_property(HttpMessage_Uri_ce, getThis(), ZEND_STRL("query"), 0, &rv); + value = zend_read_property(HttpMessage_Uri_ce, PROPERTY_ARG(getThis()), ZEND_STRL("query"), 0, &rv); RETURN_ZVAL(value, 1, 0); } @@ -369,9 +369,9 @@ PHP_METHOD(Uri, withQuery) Z_PARAM_STR(value) ZEND_PARSE_PARAMETERS_END(); - ZVAL_OBJ(return_value, zend_objects_clone_obj(getThis())); + ZVAL_OBJ(return_value, zend_objects_clone_obj(PROPERTY_ARG(getThis()))); - zend_update_property_str(HttpMessage_Uri_ce, return_value, ZEND_STRL("query"), value); + zend_update_property_str(HttpMessage_Uri_ce, PROPERTY_ARG(return_value), ZEND_STRL("query"), value); } @@ -381,7 +381,7 @@ PHP_METHOD(Uri, getFragment) { zval rv, *value; - value = zend_read_property(HttpMessage_Uri_ce, getThis(), ZEND_STRL("fragment"), 0, &rv); + value = zend_read_property(HttpMessage_Uri_ce, PROPERTY_ARG(getThis()), ZEND_STRL("fragment"), 0, &rv); RETURN_ZVAL(value, 1, 0); } @@ -394,9 +394,9 @@ PHP_METHOD(Uri, withFragment) Z_PARAM_STR(value) ZEND_PARSE_PARAMETERS_END(); - ZVAL_OBJ(return_value, zend_objects_clone_obj(getThis())); + ZVAL_OBJ(return_value, zend_objects_clone_obj(PROPERTY_ARG(getThis()))); - zend_update_property_str(HttpMessage_Uri_ce, return_value, ZEND_STRL("fragment"), value); + zend_update_property_str(HttpMessage_Uri_ce, PROPERTY_ARG(return_value), ZEND_STRL("fragment"), value); }