From 361fe5d03045eb5b4a0803eb1107a756840de4ce Mon Sep 17 00:00:00 2001
From: bryceliu <liudezhiabc@126.com>
Date: Tue, 20 Jan 2015 10:15:06 +0800
Subject: [PATCH 1/4] fixbug: when call json_encode or toArray, fields of BYTES
 are encoded to zero

---
 json_serializer.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/json_serializer.c b/json_serializer.c
index 7152954..e2b4c10 100644
--- a/json_serializer.c
+++ b/json_serializer.c
@@ -611,6 +611,7 @@ static int php_protocolbuffers_json_encode_value(zval **element, php_protocolbuf
 			}
 
 			ser->serialize_bytes(Z_STRVAL_PP(element), Z_STRLEN_PP(element), scheme, container, outer TSRMLS_CC);
+            break;
 		case TYPE_UINT32:
 		{
 			uint32_t v;
@@ -628,7 +629,6 @@ static int php_protocolbuffers_json_encode_value(zval **element, php_protocolbuf
 			ser->serialize_enum((int32_t)Z_LVAL_P(&value_copy), scheme, container, outer TSRMLS_CC);
 			zval_dtor(&value_copy);
 			break;
-		break;
 		case TYPE_SFIXED32:
 		{
 			int32_t v;
@@ -669,9 +669,8 @@ static int php_protocolbuffers_json_encode_value(zval **element, php_protocolbuf
 			zval_dtor(&value_copy);
 			break;
 		}
-		break;
 		default:
-		break;
+		    break;
 	}
 
 	return 0;

From b54cb2032b933fd3b4866705f48dd866d42ba42c Mon Sep 17 00:00:00 2001
From: hellofreedom <liudezhiabc@126.com>
Date: Tue, 28 Apr 2015 11:48:48 +0800
Subject: [PATCH 2/4] add strict flag for setting messages' properties

---
 core.c                                  | 182 ++++++-------
 core.h                                  |   2 +-
 core_inl.h                              | 328 ++++++++++++------------
 message.c                               |  95 +++----
 php_protocolbuffers.h                   |   3 +-
 protocolbuffers.c                       |  17 --
 tests/004_decode_bool.phpt              |  15 --
 tests/004_decode_bytes.phpt             |  15 --
 tests/004_decode_double_sample.phpt     |  14 +-
 tests/004_decode_fixed32_init.phpt      |  16 +-
 tests/004_decode_fixed32_max.phpt       |  16 +-
 tests/004_decode_float_sample.phpt      |  16 +-
 tests/004_decode_float_signed.phpt      |  16 +-
 tests/004_decode_int32_init.phpt        |  16 +-
 tests/004_decode_int32_max.phpt         |  16 +-
 tests/004_decode_int32_min.phpt         |  15 +-
 tests/004_decode_sfixed32_signed.phpt   |  16 +-
 tests/004_decode_sfixed32_unsigned.phpt |  16 +-
 tests/004_decode_sint32_init.phpt       |  16 +-
 tests/004_decode_sint32_max.phpt        |  16 +-
 tests/004_decode_sint32_min.phpt        |  17 +-
 tests/004_decode_string_0bytes.phpt     |  16 +-
 tests/004_decode_string_1024bytes.phpt  |  16 +-
 tests/005_decode_bool_packed.phpt       |  19 +-
 tests/005_decode_double_packed.phpt     |  20 +-
 tests/005_decode_fixed32_packed.phpt    |  20 +-
 tests/005_decode_fixed64_packed.phpt    |  19 +-
 tests/005_decode_float_packed.phpt      |  20 +-
 tests/005_decode_int32_packed.phpt      |  20 +-
 tests/005_decode_int32_packed_many.phpt |  28 +-
 tests/005_decode_int64_packed.phpt      |  20 +-
 tests/005_decode_sfixed32_packed.phpt   |  19 +-
 tests/005_decode_sfixed64_packed.phpt   |  20 +-
 tests/005_decode_sint32_packed.phpt     |  19 +-
 tests/005_decode_sint64_packed.phpt     |  20 +-
 unknown_field.c                         |  16 +-
 36 files changed, 329 insertions(+), 826 deletions(-)

diff --git a/core.c b/core.c
index 57bcfa5..22a65bd 100644
--- a/core.c
+++ b/core.c
@@ -11,7 +11,8 @@ static int single_property_name_default_len = sizeof("_properties");
 static char *unknown_property_name_default = "_unknown";
 static int unknown_property_name_default_len = sizeof("_unknown");
 
-const char* php_protocolbuffers_decode_message(INTERNAL_FUNCTION_PARAMETERS, const char *data, const char *data_end, php_protocolbuffers_scheme_container *container, int native_scalars, zval **result);
+static const char* php_protocolbuffers_decode_message(INTERNAL_FUNCTION_PARAMETERS, const char *data, const char *data_end, php_protocolbuffers_scheme_container *container, zval **result);
+
 
 int php_protocolbuffers_read_protected_property(zval *instance, char *name, size_t name_len, zval **result TSRMLS_DC)
 {
@@ -255,107 +256,76 @@ void php_protocolbuffers_process_unknown_field_bytes(INTERNAL_FUNCTION_PARAMETER
 	}
 }
 
-void php_protocolbuffers_format_string(zval *result, pbf *payload, int native_scalars TSRMLS_DC)
+void php_protocolbuffers_format_string(zval *result, pbf *payload TSRMLS_DC)
 {
 	char __buffer[64] = {0};
 	char *buffer = __buffer;
 	int free = 0;
 	size_t size = 0;
 
-	if (native_scalars == 1) {
-		switch (payload->type) {
-			case TYPE_SINT32:
-			case TYPE_INT32:
-				ZVAL_LONG(result, payload->value.int32);
-				break;
-			case TYPE_UINT32:
-				ZVAL_LONG(result, payload->value.uint32);
-				break;
-			case TYPE_UINT64:
-				ZVAL_LONG(result, payload->value.uint64);
-				break;
-			case TYPE_SINT64:
-			case TYPE_INT64:
-				ZVAL_LONG(result, payload->value.int64);
-				break;
-			break;
-			case TYPE_FLOAT:
-				ZVAL_DOUBLE(result, payload->value.f);
-				break;
-			case TYPE_DOUBLE:
-				ZVAL_DOUBLE(result, payload->value.d);
-				break;
-			break;
-			default:
-				zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "the type %d does not support. maybe this is bug", payload->type);
-				return;
-			break;
-		}
-	} else {
-		switch (payload->type) {
-			case TYPE_SINT32:
-			case TYPE_INT32:
-				size = snprintf(buffer, sizeof(__buffer), "%d", payload->value.int32);
-			break;
-			case TYPE_UINT32:
-				size = snprintf(buffer, sizeof(__buffer), "%u", payload->value.uint32);
-			break;
-			case TYPE_UINT64:
-				size = snprintf(buffer, sizeof(__buffer), "%llu" , payload->value.uint64);
-			break;
-			case TYPE_SINT64:
-			case TYPE_INT64:
-				size = snprintf(buffer, sizeof(__buffer), "%lld" , payload->value.int64);
-			break;
-			case TYPE_FLOAT:{
-				char *p = 0;
-				free = 1;
-
-				/* Note: this is safe */
-				buffer = emalloc(MAX_LENGTH_OF_DOUBLE + EG(precision) + 1);
-				size = zend_sprintf(buffer, "%f", payload->value.f);
-
-				// remove trailing zeros
-				p = strchr(buffer,'.');
-				if(p != NULL) {
-					while(*++p);
-
-					while('0' == *--p){
-						*p = '\0';
-						size--;
-					}
-
-					if(*p == '.'){
-						*p = '\0';
-						size--;
-					}
-					break;
+	switch (payload->type) {
+		case TYPE_SINT32:
+		case TYPE_INT32:
+			size = snprintf(buffer, sizeof(__buffer), "%d", payload->value.int32);
+		break;
+		case TYPE_UINT32:
+			size = snprintf(buffer, sizeof(__buffer), "%u", payload->value.uint32);
+		break;
+		case TYPE_UINT64:
+			size = snprintf(buffer, sizeof(__buffer), "%llu" , payload->value.uint64);
+		break;
+		case TYPE_SINT64:
+		case TYPE_INT64:
+			size = snprintf(buffer, sizeof(__buffer), "%lld" , payload->value.int64);
+		break;
+		case TYPE_FLOAT:{
+			char *p = 0;
+			free = 1;
+
+ 			/* Note: this is safe */
+			buffer = emalloc(MAX_LENGTH_OF_DOUBLE + EG(precision) + 1);
+			size = zend_sprintf(buffer, "%f", payload->value.f);
+
+			// remove trailing zeros
+			p = strchr(buffer,'.');
+			if(p != NULL) {
+				while(*++p);
+
+				while('0' == *--p){
+					*p = '\0';
+					size--;
 				}
+
+				if(*p == '.'){
+					*p = '\0';
+					size--;
 				}
-			break;
-			case TYPE_DOUBLE:{
-				free = 1;
-				/* Note: this is safe */
-				buffer = emalloc(MAX_LENGTH_OF_DOUBLE + EG(precision) + 1);
-				size = zend_sprintf(buffer, "%.*G", (int)EG(precision), payload->value.d);
+				break;
 			}
-			break;
-			default:
-				zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "the type %d does not support. maybe this is bug", payload->type);
-				return;
-			break;
+  		}
+		break;
+		case TYPE_DOUBLE:{
+			free = 1;
+ 			/* Note: this is safe */
+			buffer = emalloc(MAX_LENGTH_OF_DOUBLE + EG(precision) + 1);
+			size = zend_sprintf(buffer, "%.*G", (int)EG(precision), payload->value.d);
 		}
+		break;
+		default:
+			zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "the type %d does not support. maybe this is bug", payload->type);
+			return;
+		break;
+	}
 
-		if (buffer != NULL) {
-			ZVAL_STRINGL(result, buffer, size, 1);
-		}
-		if (free) {
-			efree(buffer);
-		}
+	if (buffer != NULL) {
+		ZVAL_STRINGL(result, buffer, size, 1);
+	}
+	if (free) {
+		efree(buffer);
 	}
 }
 
-const char* php_protocolbuffers_decode_message(INTERNAL_FUNCTION_PARAMETERS, const char *data, const char *data_end, php_protocolbuffers_scheme_container *container, int native_scalars, zval **result)
+const char* php_protocolbuffers_decode_message(INTERNAL_FUNCTION_PARAMETERS, const char *data, const char *data_end, php_protocolbuffers_scheme_container *container, zval **result)
 {
 	uint32_t payload = 0, tag = 0, wiretype = 0;
 	uint64_t value = 0;
@@ -410,14 +380,14 @@ const char* php_protocolbuffers_decode_message(INTERNAL_FUNCTION_PARAMETERS, con
 		case WIRETYPE_VARINT:
 		{
 			data = ReadVarint64FromArray(data, &value, data_end);
-			if (!php_protocolbuffers_process_varint(INTERNAL_FUNCTION_PARAM_PASSTHRU, wiretype, tag, container, s, value, hresult, native_scalars)) {
+			if (!php_protocolbuffers_process_varint(INTERNAL_FUNCTION_PARAM_PASSTHRU, wiretype, tag, container, s, value, hresult)) {
 				return NULL;
 			}
 		}
 		break;
 		case WIRETYPE_FIXED64:
-			if (!php_protocolbuffers_process_fixed64(INTERNAL_FUNCTION_PARAM_PASSTHRU, wiretype, tag, container, s, data, hresult, native_scalars)) {
-				return NULL;
+			if (!php_protocolbuffers_process_fixed64(INTERNAL_FUNCTION_PARAM_PASSTHRU, wiretype, tag, container, s, data, hresult)) {
+            	return NULL;
 			}
 			data += 8;
 		break;
@@ -491,7 +461,7 @@ const char* php_protocolbuffers_decode_message(INTERNAL_FUNCTION_PARAMETERS, con
 					}
 				}
 
-				php_protocolbuffers_decode_message(INTERNAL_FUNCTION_PARAM_PASSTHRU, data, n_buffer_end, c_container, PBG(native_scalars), &z_obj);
+				php_protocolbuffers_decode_message(INTERNAL_FUNCTION_PARAM_PASSTHRU, data, n_buffer_end, c_container, &z_obj);
 
 				if (c_container->use_wakeup_and_sleep > 0) {
 					php_protocolbuffers_execute_wakeup(z_obj, c_container TSRMLS_CC);
@@ -540,7 +510,7 @@ const char* php_protocolbuffers_decode_message(INTERNAL_FUNCTION_PARAMETERS, con
 							MAKE_STD_ZVAL(dz);
 
 							__payload.type = TYPE_DOUBLE;__payload.value.d = d;
-							php_protocolbuffers_format_string(dz, &__payload, native_scalars TSRMLS_CC);
+							php_protocolbuffers_format_string(dz, &__payload TSRMLS_CC);
 							php_protocolbuffers_decode_add_value_and_consider_repeated(container, s, hresult, dz TSRMLS_CC);
 
 							data += 8;
@@ -557,7 +527,7 @@ const char* php_protocolbuffers_decode_message(INTERNAL_FUNCTION_PARAMETERS, con
 							MAKE_STD_ZVAL(dz);
 
 							__payload.type = TYPE_DOUBLE;__payload.value.d = a;
-							php_protocolbuffers_format_string(dz, &__payload, native_scalars TSRMLS_CC);
+							php_protocolbuffers_format_string(dz, &__payload TSRMLS_CC);
 
 							php_protocolbuffers_decode_add_value_and_consider_repeated(container, s, hresult, dz TSRMLS_CC);
 
@@ -572,7 +542,7 @@ const char* php_protocolbuffers_decode_message(INTERNAL_FUNCTION_PARAMETERS, con
 							MAKE_STD_ZVAL(dz);
 
 							__payload.type = TYPE_INT64;__payload.value.int64 = v2;
-							php_protocolbuffers_format_string(dz, &__payload, native_scalars TSRMLS_CC);
+							php_protocolbuffers_format_string(dz, &__payload TSRMLS_CC);
 
 							php_protocolbuffers_decode_add_value_and_consider_repeated(container, s, hresult, dz TSRMLS_CC);
 						}
@@ -585,7 +555,7 @@ const char* php_protocolbuffers_decode_message(INTERNAL_FUNCTION_PARAMETERS, con
 							MAKE_STD_ZVAL(dz);
 
 							__payload.type = TYPE_UINT64;__payload.value.uint64 = v2;
-							php_protocolbuffers_format_string(dz, &__payload, native_scalars TSRMLS_CC);
+							php_protocolbuffers_format_string(dz, &__payload TSRMLS_CC);
 
 							php_protocolbuffers_decode_add_value_and_consider_repeated(container, s, hresult, dz TSRMLS_CC);
 						}
@@ -597,7 +567,7 @@ const char* php_protocolbuffers_decode_message(INTERNAL_FUNCTION_PARAMETERS, con
 							MAKE_STD_ZVAL(dz);
 
 							__payload.type = TYPE_INT32;__payload.value.int32 = (int32_t)payload;
-							php_protocolbuffers_format_string(dz, &__payload, native_scalars TSRMLS_CC);
+							php_protocolbuffers_format_string(dz, &__payload TSRMLS_CC);
 
 							php_protocolbuffers_decode_add_value_and_consider_repeated(container, s, hresult, dz TSRMLS_CC);
 						break;
@@ -608,7 +578,7 @@ const char* php_protocolbuffers_decode_message(INTERNAL_FUNCTION_PARAMETERS, con
 
 							MAKE_STD_ZVAL(dz);
 							__payload.type = TYPE_UINT64;__payload.value.uint64 = l;
-							php_protocolbuffers_format_string(dz, &__payload, native_scalars TSRMLS_CC);
+							php_protocolbuffers_format_string(dz, &__payload TSRMLS_CC);
 
 							php_protocolbuffers_decode_add_value_and_consider_repeated(container, s, hresult, dz TSRMLS_CC);
 							data += 8;
@@ -621,7 +591,7 @@ const char* php_protocolbuffers_decode_message(INTERNAL_FUNCTION_PARAMETERS, con
 
 							MAKE_STD_ZVAL(dz);
 							__payload.type = TYPE_UINT32;__payload.value.uint32 = l;
-							php_protocolbuffers_format_string(dz, &__payload, native_scalars TSRMLS_CC);
+							php_protocolbuffers_format_string(dz, &__payload TSRMLS_CC);
 
 							php_protocolbuffers_decode_add_value_and_consider_repeated(container, s, hresult, dz TSRMLS_CC);
 
@@ -641,7 +611,7 @@ const char* php_protocolbuffers_decode_message(INTERNAL_FUNCTION_PARAMETERS, con
 
 							MAKE_STD_ZVAL(dz);
 							__payload.type = TYPE_UINT32;__payload.value.uint32 = (uint32_t)payload;
-							php_protocolbuffers_format_string(dz, &__payload, native_scalars TSRMLS_CC);
+							php_protocolbuffers_format_string(dz, &__payload TSRMLS_CC);
 
 							php_protocolbuffers_decode_add_value_and_consider_repeated(container, s, hresult, dz TSRMLS_CC);
 						break;
@@ -661,7 +631,7 @@ const char* php_protocolbuffers_decode_message(INTERNAL_FUNCTION_PARAMETERS, con
 							MAKE_STD_ZVAL(dz);
 
 							__payload.type = TYPE_INT32;__payload.value.int32 = l;
-							php_protocolbuffers_format_string(dz, &__payload, native_scalars TSRMLS_CC);
+							php_protocolbuffers_format_string(dz, &__payload TSRMLS_CC);
 
 							php_protocolbuffers_decode_add_value_and_consider_repeated(container, s, hresult, dz TSRMLS_CC);
 							data += 4;
@@ -674,7 +644,7 @@ const char* php_protocolbuffers_decode_message(INTERNAL_FUNCTION_PARAMETERS, con
 
 							MAKE_STD_ZVAL(dz);
 							__payload.type = TYPE_INT64;__payload.value.int64 = l;
-							php_protocolbuffers_format_string(dz, &__payload, native_scalars TSRMLS_CC);
+							php_protocolbuffers_format_string(dz, &__payload TSRMLS_CC);
 
 							php_protocolbuffers_decode_add_value_and_consider_repeated(container, s, hresult, dz TSRMLS_CC);
 
@@ -686,7 +656,7 @@ const char* php_protocolbuffers_decode_message(INTERNAL_FUNCTION_PARAMETERS, con
 
 							MAKE_STD_ZVAL(dz);
 							__payload.type = TYPE_INT32;__payload.value.int32 = (int32_t)zigzag_decode32(payload);
-							php_protocolbuffers_format_string(dz, &__payload, native_scalars TSRMLS_CC);
+							php_protocolbuffers_format_string(dz, &__payload TSRMLS_CC);
 
 							php_protocolbuffers_decode_add_value_and_consider_repeated(container, s, hresult, dz TSRMLS_CC);
 						break;
@@ -698,7 +668,7 @@ const char* php_protocolbuffers_decode_message(INTERNAL_FUNCTION_PARAMETERS, con
 							MAKE_STD_ZVAL(dz);
 
 							__payload.type = TYPE_SINT64;__payload.value.int64 = (int64_t)zigzag_decode64(v2);
-							php_protocolbuffers_format_string(dz, &__payload, native_scalars TSRMLS_CC);
+							php_protocolbuffers_format_string(dz, &__payload TSRMLS_CC);
 
 							php_protocolbuffers_decode_add_value_and_consider_repeated(container, s, hresult, dz TSRMLS_CC);
 						}
@@ -717,7 +687,7 @@ const char* php_protocolbuffers_decode_message(INTERNAL_FUNCTION_PARAMETERS, con
 			data += payload;
 		break;
 		case WIRETYPE_FIXED32: {
-			if (!php_protocolbuffers_process_fixed32(INTERNAL_FUNCTION_PARAM_PASSTHRU, wiretype, tag, container, s, data, hresult, native_scalars)) {
+			if (!php_protocolbuffers_process_fixed32(INTERNAL_FUNCTION_PARAM_PASSTHRU, wiretype, tag, container, s, data, hresult)) {
 				return NULL;
 			}
 			data += 4;
@@ -857,7 +827,7 @@ int php_protocolbuffers_decode(INTERNAL_FUNCTION_PARAMETERS, const char *data, i
 		efree(unknown_name);
 	}
 
-	res = php_protocolbuffers_decode_message(INTERNAL_FUNCTION_PARAM_PASSTHRU, data, data_end, container, PBG(native_scalars), &obj);
+	res = php_protocolbuffers_decode_message(INTERNAL_FUNCTION_PARAM_PASSTHRU, data, data_end, container, &obj);
 	if (res == NULL) {
 		if (obj != NULL) {
 			zval_ptr_dtor(&obj);
diff --git a/core.h b/core.h
index a948459..fff5853 100644
--- a/core.h
+++ b/core.h
@@ -76,7 +76,7 @@ int php_protocolbuffers_get_scheme_container(const char *klass, size_t klass_len
 
 int php_protocolbuffers_get_scheme_container_ex(const char *klass, size_t klass_len, int throws_exception, php_protocolbuffers_scheme_container **result TSRMLS_DC);
 
-void php_protocolbuffers_format_string(zval *result, pbf *payload, int use_string TSRMLS_DC);
+void php_protocolbuffers_format_string(zval *result, pbf *payload TSRMLS_DC);
 
 void php_protocolbuffers_execute_wakeup(zval *obj, php_protocolbuffers_scheme_container *container TSRMLS_DC);
 
diff --git a/core_inl.h b/core_inl.h
index bf39d8f..dcc7e2c 100644
--- a/core_inl.h
+++ b/core_inl.h
@@ -3,207 +3,207 @@
 
 static inline int is_utf8(const char *s, int len)
 {
-	int i;
-	const unsigned char *bytes = (const unsigned char *)s;
-
-	if (len < 1) {
-		/* NOTE: always return 1 when passed string is null */
-		return 1;
-	}
-
-	for (i = 0; i < len; i++) {
-		/* ASCII */
-		if (bytes[0] == 0x09 ||
-				bytes[0] == 0x0A ||
-				bytes[0] == 0x0D ||
-				(bytes[0] >= 0x20 && bytes[0] <= 0x7E)
-		) {
-			bytes += 1;
-			continue;
-		}
-
-		/* non-overlong 2-byte */
-		if (((i+1) <= len) &&
-				(bytes[0] >= 0xC2 && bytes[0] <= 0xDF) &&
-				(bytes[1] >= 0x80 && bytes[1] <= 0xBF)) {
-			bytes += 2;
-			i+=1;
-			continue;
-		}
-
-		/* excluding overlongs */
-		if (((i+2) <= len) &&
-			bytes[0] == 0xE0 &&
-			(bytes[1] >= 0xA0 && bytes[1] <= 0xBF) &&
-			(bytes[2] >= 0x80 && bytes[2] <= 0xBF)
-		) {
-			bytes += 3;
-			i+=2;
-			continue;
-		}
-
-		/* straight 3-byte */
-		if (((i+2) <= len) &&
-			((bytes[0] >= 0xE1 && bytes[0] <= 0xEC) ||
-				bytes[0] == 0xEE ||
-				bytes[0] == 0xEF) &&
-				(bytes[1] >= 0x80 && bytes[1] <= 0xBF) &&
-				(bytes[2] >= 0x80 && bytes[2] <= 0xBF)
-				) {
-					bytes += 3;
-					i+=2;
-					continue;
-		}
-
-		/* excluding surrogates */
-		if (((i+2) <= len) &&
-			bytes[0] == 0xED &&
-			(bytes[1] >= 0x80 && bytes[1] <= 0x9F) &&
-			(bytes[2] >= 0x80 && bytes[2] <= 0xBF)
-		) {
-				bytes += 3;
-				i+=2;
-				continue;
-		}
-
-		/* planes 1-3 */
-		if (((i+3) <= len) &&
-			bytes[0] == 0xF0 &&
-			(bytes[1] >= 0x90 && bytes[1] <= 0xBF) &&
-			(bytes[2] >= 0x80 && bytes[2] <= 0xBF) &&
-			(bytes[3] >= 0x80 && bytes[3] <= 0xBF)
-		) {
-				bytes += 4;
-				i+=3;
-				continue;
-		}
-
-		/* planes 4-15 */
-		if (((i+3) <= len) &&
-			bytes[0] >= 0xF1 && bytes[0] <= 0xF3 &&
-			bytes[1] >= 0x80 && bytes[1] <= 0xBF &&
-			bytes[2] >= 0x80 && bytes[2] <= 0xBF &&
-			bytes[3] >= 0x80 && bytes[3] <= 0xBF
-		) {
-				bytes += 4;
-				i+=3;
-				continue;
-		}
-
-		/* plane 16 */
-		if (((i+3) <= len) &&
-			bytes[0] == 0xF4 &&
-			(bytes[1] >= 0x80 && bytes[1] <= 0x8F) &&
-			(bytes[2] >= 0x80 && bytes[2] <= 0xBF) &&
-			(bytes[3] >= 0x80 && bytes[3] <= 0xBF)
-		) {
-				bytes += 4;
-				i+=3;
-				continue;
-		}
-
-		return 0;
-	}
-
-	return 1;
+    int i;
+    const unsigned char *bytes = (const unsigned char *)s;
+
+    if (len < 1) {
+      /* NOTE: always return 1 when passed string is null */
+      return 1;
+    }
+
+    for (i = 0; i < len; i++) {
+      /* ASCII */
+      if (bytes[0] == 0x09 ||
+          bytes[0] == 0x0A ||
+          bytes[0] == 0x0D ||
+          (bytes[0] >= 0x20 && bytes[0] <= 0x7E)
+      ) {
+        bytes += 1;
+        continue;
+      }
+
+      /* non-overlong 2-byte */
+      if (((i+1) <= len) &&
+          (bytes[0] >= 0xC2 && bytes[0] <= 0xDF) &&
+          (bytes[1] >= 0x80 && bytes[1] <= 0xBF)) {
+        bytes += 2;
+        i+=1;
+        continue;
+      }
+
+      /* excluding overlongs */
+      if (((i+2) <= len) &&
+        bytes[0] == 0xE0 &&
+        (bytes[1] >= 0xA0 && bytes[1] <= 0xBF) &&
+        (bytes[2] >= 0x80 && bytes[2] <= 0xBF)
+      ) {
+        bytes += 3;
+        i+=2;
+        continue;
+      }
+
+      /* straight 3-byte */
+      if (((i+2) <= len) &&
+        ((bytes[0] >= 0xE1 && bytes[0] <= 0xEC) ||
+          bytes[0] == 0xEE ||
+          bytes[0] == 0xEF) &&
+          (bytes[1] >= 0x80 && bytes[1] <= 0xBF) &&
+          (bytes[2] >= 0x80 && bytes[2] <= 0xBF)
+          ) {
+            bytes += 3;
+            i+=2;
+            continue;
+      }
+
+      /* excluding surrogates */
+      if (((i+2) <= len) &&
+        bytes[0] == 0xED &&
+        (bytes[1] >= 0x80 && bytes[1] <= 0x9F) &&
+        (bytes[2] >= 0x80 && bytes[2] <= 0xBF)
+      ) {
+          bytes += 3;
+          i+=2;
+          continue;
+      }
+
+      /* planes 1-3 */
+      if (((i+3) <= len) &&
+        bytes[0] == 0xF0 &&
+        (bytes[1] >= 0x90 && bytes[1] <= 0xBF) &&
+        (bytes[2] >= 0x80 && bytes[2] <= 0xBF) &&
+        (bytes[3] >= 0x80 && bytes[3] <= 0xBF)
+      ) {
+          bytes += 4;
+          i+=3;
+          continue;
+      }
+
+      /* planes 4-15 */
+      if (((i+3) <= len) &&
+        bytes[0] >= 0xF1 && bytes[0] <= 0xF3 &&
+        bytes[1] >= 0x80 && bytes[1] <= 0xBF &&
+        bytes[2] >= 0x80 && bytes[2] <= 0xBF &&
+        bytes[3] >= 0x80 && bytes[3] <= 0xBF
+      ) {
+          bytes += 4;
+          i+=3;
+          continue;
+      }
+
+      /* plane 16 */
+      if (((i+3) <= len) &&
+        bytes[0] == 0xF4 &&
+        (bytes[1] >= 0x80 && bytes[1] <= 0x8F) &&
+        (bytes[2] >= 0x80 && bytes[2] <= 0xBF) &&
+        (bytes[3] >= 0x80 && bytes[3] <= 0xBF)
+      ) {
+          bytes += 4;
+          i+=3;
+          continue;
+      }
+
+      return 0;
+    }
+
+    return 1;
 }
 
 
 static inline uint32_t zigzag_encode32(int32_t n) {
-	// Note:  the right-shift must be arithmetic
-	return (n << 1) ^ (n >> 31);
+  // Note:  the right-shift must be arithmetic
+  return (n << 1) ^ (n >> 31);
 }
 
 static inline int32_t zigzag_decode32(uint32_t n) {
-	return (n >> 1) ^ - (int32_t)(n & 1);
+  return (n >> 1) ^ - (int32_t)(n & 1);
 }
 
 static inline uint64_t zigzag_encode64(int64_t n) {
-	// Note:  the right-shift must be arithmetic
-	return (n << 1) ^ (n >> 63);
+  // Note:  the right-shift must be arithmetic
+  return (n << 1) ^ (n >> 63);
 }
 
 static inline int64_t zigzag_decode64(uint64_t n) {
-	return (n >> 1) ^ - (int64_t)(n & 1);
+  return (n >> 1) ^ - (int64_t)(n & 1);
 }
 
 static inline uint64_t encode_double(double value) {
-	union {
-		double d;
-		uint64_t v;
-	} u;
-	u.d = value;
+    union {
+        double d;
+        uint64_t v;
+    } u;
+    u.d = value;
 
-	return u.v;
+    return u.v;
 }
 
 static inline double decode_double(uint64_t value) {
-	union {
-		double d;
-		uint64_t v;
-	} u;
-	u.v = value;
+    union {
+        double d;
+        uint64_t v;
+    } u;
+    u.v = value;
 
-	return u.d;
+    return u.d;
 }
 
 static inline uint32_t encode_float(float value) {
-	union {
-		float f;
-		uint32_t v;
-	} u;
-	u.f = value;
+    union {
+        float f;
+        uint32_t v;
+    } u;
+    u.f = value;
 
-	return u.v;
+    return u.v;
 }
 
 static inline float decode_float(int32_t value) {
-	union {
-		float f;
-		uint32_t v;
-	} u;
-	u.v = value;
+    union {
+        float f;
+        uint32_t v;
+    } u;
+    u.v = value;
 
-	return u.f;
+    return u.f;
 }
 
 static inline int php_protocolbuffers_get_lval_from_hash_by_tag(HashTable *proto, ulong tag, const char *name, size_t name_len TSRMLS_DC)
 {
-	zval **d, **dd;
+    zval **d, **dd;
 
-	if (zend_hash_index_find(proto, tag, (void **)&d) != SUCCESS) {
-		return 0;
-	}
+    if (zend_hash_index_find(proto, tag, (void **)&d) != SUCCESS) {
+        return 0;
+    }
 
-	if (Z_TYPE_PP(d) != IS_ARRAY) {
-		return 0;
-	}
+    if (Z_TYPE_PP(d) != IS_ARRAY) {
+        return 0;
+    }
 
-	if (zend_hash_find(Z_ARRVAL_PP(d), (char*)name, name_len, (void **)&dd) == SUCCESS) {
-		return Z_LVAL_PP(dd);
-	}
+    if (zend_hash_find(Z_ARRVAL_PP(d), (char*)name, name_len, (void **)&dd) == SUCCESS) {
+        return Z_LVAL_PP(dd);
+    }
 
-	return 0;
+    return 0;
 }
 
 static inline int php_protocolbuffers_get_zval_from_hash_by_tag(HashTable *proto, ulong tag, const char *name, size_t name_len, zval **result TSRMLS_DC)
 {
-	zval **d, **dd;
+    zval **d, **dd;
 
-	if (zend_hash_index_find(proto, tag, (void **)&d) != SUCCESS) {
-		return 0;
-	}
+    if (zend_hash_index_find(proto, tag, (void **)&d) != SUCCESS) {
+        return 0;
+    }
 
-	if (Z_TYPE_PP(d) != IS_ARRAY) {
-		return 0;
-	}
+    if (Z_TYPE_PP(d) != IS_ARRAY) {
+        return 0;
+    }
 
-	if (zend_hash_find(Z_ARRVAL_PP(d), (char*)name, name_len, (void **)&dd) == SUCCESS) {
-		*result = *dd;
-		return 1;
-	}
+    if (zend_hash_find(Z_ARRVAL_PP(d), (char*)name, name_len, (void **)&dd) == SUCCESS) {
+        *result = *dd;
+        return 1;
+    }
 
-	return 0;
+    return 0;
 }
 
 static inline const char* ReadVarint32FromArray(const char* buffer, uint* value, const char* buffer_end) {
@@ -344,7 +344,7 @@ static inline void php_protocolbuffers_decode_add_value_and_consider_repeated(ph
 	}
 }
 
-static inline int php_protocolbuffers_process_varint(INTERNAL_FUNCTION_PARAMETERS, int wiretype, int tag, php_protocolbuffers_scheme_container *container, php_protocolbuffers_scheme *scheme, uint64_t value, HashTable *hresult, int use_string)
+static inline int php_protocolbuffers_process_varint(INTERNAL_FUNCTION_PARAMETERS, int wiretype, int tag, php_protocolbuffers_scheme_container *container, php_protocolbuffers_scheme *scheme, uint64_t value, HashTable *hresult)
 {
 	pbf __payload = {0};
 	zval *dz = NULL;
@@ -386,7 +386,7 @@ static inline int php_protocolbuffers_process_varint(INTERNAL_FUNCTION_PARAMETER
 				return 0;
 		}
 		if (scheme->type != TYPE_BOOL) {
-			php_protocolbuffers_format_string(dz, &__payload, use_string TSRMLS_CC);
+			php_protocolbuffers_format_string(dz, &__payload TSRMLS_CC);
 		}
 
 		php_protocolbuffers_decode_add_value_and_consider_repeated(container, scheme, hresult, dz TSRMLS_CC);
@@ -395,7 +395,7 @@ static inline int php_protocolbuffers_process_varint(INTERNAL_FUNCTION_PARAMETER
 	return 1;
 }
 
-static inline int php_protocolbuffers_process_fixed64(INTERNAL_FUNCTION_PARAMETERS, int wiretype, int tag, php_protocolbuffers_scheme_container *container, php_protocolbuffers_scheme *scheme, const char *data, HashTable *hresult, int use_string)
+static inline int php_protocolbuffers_process_fixed64(INTERNAL_FUNCTION_PARAMETERS, int wiretype, int tag, php_protocolbuffers_scheme_container *container, php_protocolbuffers_scheme *scheme, const char *data, HashTable *hresult)
 {
 	pbf __payload = {0};
 	zval *dz = NULL;
@@ -419,7 +419,7 @@ static inline int php_protocolbuffers_process_fixed64(INTERNAL_FUNCTION_PARAMETE
 				d = decode_double(v);
 
 				__payload.type = TYPE_DOUBLE;__payload.value.d = d;
-				php_protocolbuffers_format_string(dz, &__payload, use_string TSRMLS_CC);
+				php_protocolbuffers_format_string(dz, &__payload TSRMLS_CC);
 			}
 			break;
 			case TYPE_FIXED64:
@@ -428,7 +428,7 @@ static inline int php_protocolbuffers_process_fixed64(INTERNAL_FUNCTION_PARAMETE
 
 				memcpy(&v, data, 8);
 				__payload.type = TYPE_UINT64;__payload.value.uint64 = v;
-				php_protocolbuffers_format_string(dz, &__payload, use_string TSRMLS_CC);
+				php_protocolbuffers_format_string(dz, &__payload TSRMLS_CC);
 			}
 			break;
 			case TYPE_SFIXED64:
@@ -437,7 +437,7 @@ static inline int php_protocolbuffers_process_fixed64(INTERNAL_FUNCTION_PARAMETE
 				memcpy(&l, data, 8);
 
 				__payload.type = TYPE_INT64;__payload.value.int64 = l;
-				php_protocolbuffers_format_string(dz, &__payload, use_string TSRMLS_CC);
+				php_protocolbuffers_format_string(dz, &__payload TSRMLS_CC);
 			}
 			break;
 			default:
@@ -450,7 +450,7 @@ static inline int php_protocolbuffers_process_fixed64(INTERNAL_FUNCTION_PARAMETE
 	return 1;
 }
 
-static inline int php_protocolbuffers_process_fixed32(INTERNAL_FUNCTION_PARAMETERS, int wiretype, int tag, php_protocolbuffers_scheme_container *container, php_protocolbuffers_scheme *scheme, const char *data, HashTable *hresult, int use_string)
+static inline int php_protocolbuffers_process_fixed32(INTERNAL_FUNCTION_PARAMETERS, int wiretype, int tag, php_protocolbuffers_scheme_container *container, php_protocolbuffers_scheme *scheme, const char *data, HashTable *hresult)
 {
 	pbf __payload = {0};
 	zval *dz = NULL;
@@ -493,7 +493,7 @@ static inline int php_protocolbuffers_process_fixed32(INTERNAL_FUNCTION_PARAMETE
 				zval_ptr_dtor(&dz);
 				return 0;
 		}
-		php_protocolbuffers_format_string(dz, &__payload, use_string TSRMLS_CC);
+		php_protocolbuffers_format_string(dz, &__payload TSRMLS_CC);
 		php_protocolbuffers_decode_add_value_and_consider_repeated(container, scheme, hresult, dz TSRMLS_CC);
 	}
 
diff --git a/message.c b/message.c
index 955f683..3f59172 100644
--- a/message.c
+++ b/message.c
@@ -100,10 +100,12 @@ zend_object_value php_protocolbuffers_message_new(zend_class_entry *ce TSRMLS_DC
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_protocolbuffers_message___construct, 0, 0, 0)
 	ZEND_ARG_INFO(0, params)
+	ZEND_ARG_INFO(0, strict)
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_protocolbuffers_message_set_from, 0, 0, 1)
 	ZEND_ARG_INFO(0, params)
+	ZEND_ARG_INFO(0, strict)
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_protocolbuffers_message_serialize_to_string, 0, 0, 0)
@@ -478,7 +480,7 @@ static void php_protocolbuffers_message_get(INTERNAL_FUNCTION_PARAMETERS, zval *
 	}
 }
 
-static void php_protocolbuffers_message_set(INTERNAL_FUNCTION_PARAMETERS, zval *instance, php_protocolbuffers_scheme_container *container, char *name, int name_len, char *name2, int name2_len, zval *value)
+static void php_protocolbuffers_message_set(INTERNAL_FUNCTION_PARAMETERS, zval *instance, php_protocolbuffers_scheme_container *container, char *name, int name_len, char *name2, int name2_len, zval *value, zend_bool strict)
 {
 	php_protocolbuffers_scheme *scheme;
 	php_protocolbuffers_message *m;
@@ -491,8 +493,10 @@ static void php_protocolbuffers_message_set(INTERNAL_FUNCTION_PARAMETERS, zval *
 
 	scheme = php_protocolbuffers_message_get_scheme_by_name(container, name, name_len, name2, name2_len);
 	if (scheme == NULL) {
-		zval_ptr_dtor(&value);
-		zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "%s does not find", name);
+        if (strict) {
+		    zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "%s does not find", name);
+		    zval_ptr_dtor(&value);
+        }
 		return;
 	}
 
@@ -517,6 +521,10 @@ static void php_protocolbuffers_message_set(INTERNAL_FUNCTION_PARAMETERS, zval *
 				MAKE_STD_ZVAL(outer);
 				array_init(outer);
 
+                zval *zval_strict;
+                MAKE_STD_ZVAL(zval_strict);
+                ZVAL_BOOL(zval_strict, strict);
+
 				for(zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(value), &pos);
 								zend_hash_get_current_data_ex(Z_ARRVAL_P(value), (void **)&element, &pos) == SUCCESS;
 								zend_hash_move_forward_ex(Z_ARRVAL_P(value), &pos)
@@ -527,42 +535,29 @@ static void php_protocolbuffers_message_set(INTERNAL_FUNCTION_PARAMETERS, zval *
 						continue;
 					}
 
-					if (Z_TYPE_PP(element) == IS_OBJECT) {
-						if (scheme->ce != Z_OBJCE_PP(element)) {
-							zval_ptr_dtor(&outer);
-							zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "expected %s class. given %s class", scheme->ce->name, Z_OBJCE_PP(element)->name);
-							return;
-						} else {
-							m = PHP_PROTOCOLBUFFERS_GET_OBJECT(php_protocolbuffers_message, *element);
-							ZVAL_ZVAL(m->container, instance, 0, 0);
-
-							Z_ADDREF_PP(element);
-							add_next_index_zval(outer, *element);
-						}
-					} else {
-						MAKE_STD_ZVAL(child);
-						MAKE_STD_ZVAL(param);
-						ZVAL_ZVAL(param, *element, 1, 0);
+					MAKE_STD_ZVAL(child);
+					MAKE_STD_ZVAL(param);
+					ZVAL_ZVAL(param, *element, 1, 0);
 
-						object_init_ex(child, scheme->ce);
-						php_protocolbuffers_properties_init(child, scheme->ce TSRMLS_CC);
+					object_init_ex(child, scheme->ce);
+					php_protocolbuffers_properties_init(child, scheme->ce TSRMLS_CC);
 
-						zend_call_method_with_1_params(&child, scheme->ce, NULL, ZEND_CONSTRUCTOR_FUNC_NAME, NULL, param);
-						zval_ptr_dtor(&param);
-
-						m = PHP_PROTOCOLBUFFERS_GET_OBJECT(php_protocolbuffers_message, child);
-						ZVAL_ZVAL(m->container, instance, 0, 0);
-						add_next_index_zval(outer, child);
-					}
+					zend_call_method_with_2_params(&child, scheme->ce, NULL, ZEND_CONSTRUCTOR_FUNC_NAME, NULL, param, zval_strict);
+					zval_ptr_dtor(&param);
 
+					m = PHP_PROTOCOLBUFFERS_GET_OBJECT(php_protocolbuffers_message, child);
+					ZVAL_ZVAL(m->container, instance, 0, 0);
+					add_next_index_zval(outer, child);
 				}
+
+                zval_ptr_dtor(&zval_strict);
+
 				value = outer;
 				should_free = 1;
 			}
 
 		} else {
 			if (Z_TYPE_P(value) == IS_ARRAY) {
-				/* NOTE(chobie): Array to Object conversion */
 				zval *param;
 
 				MAKE_STD_ZVAL(tmp);
@@ -572,7 +567,15 @@ static void php_protocolbuffers_message_set(INTERNAL_FUNCTION_PARAMETERS, zval *
 
 				object_init_ex(tmp, scheme->ce);
 				php_protocolbuffers_properties_init(tmp, scheme->ce TSRMLS_CC);
-				zend_call_method_with_1_params(&tmp, scheme->ce, NULL, ZEND_CONSTRUCTOR_FUNC_NAME, NULL, param);
+
+                zval *zval_strict;
+                MAKE_STD_ZVAL(zval_strict);
+                ZVAL_BOOL(zval_strict, strict);
+
+				zend_call_method_with_2_params(&tmp, scheme->ce, NULL, ZEND_CONSTRUCTOR_FUNC_NAME, NULL, param, zval_strict);
+
+                zval_ptr_dtor(&zval_strict);
+
 				zval_ptr_dtor(&param);
 
 				value = tmp;
@@ -639,8 +642,8 @@ static void php_protocolbuffers_message_clear(INTERNAL_FUNCTION_PARAMETERS, zval
 		zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "clear method can't use for extension value", name);
 		return;
 	}
-
 	php_protocolbuffers_message_get_hash_table_by_container(container, scheme, instance, &htt, &n, &n_len TSRMLS_CC);
+
 	if (zend_hash_find(htt, n, n_len, (void **)&e) == SUCCESS) {
 		zval *vl = NULL;
 
@@ -764,7 +767,7 @@ static void php_protocolbuffers_message_has(INTERNAL_FUNCTION_PARAMETERS, zval *
 	}
 
 	if (scheme->is_extension) {
-		zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "has method can't use for extension value", name);
+		zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "get method can't use for extension value", name);
 		return;
 	}
 
@@ -899,7 +902,7 @@ static enum ProtocolBuffers_MagicMethod php_protocolbuffers_parse_magic_method(c
 	return flag;
 }
 
-static void php_protocolbuffers_set_from(INTERNAL_FUNCTION_PARAMETERS, zval *instance, zval *params)
+static void php_protocolbuffers_set_from(INTERNAL_FUNCTION_PARAMETERS, zval *instance, zval *params, zend_bool strict)
 {
 	HashPosition pos;
 	zval **param;
@@ -916,7 +919,7 @@ static void php_protocolbuffers_set_from(INTERNAL_FUNCTION_PARAMETERS, zval *ins
 		zend_hash_move_forward_ex(Z_ARRVAL_P(params), &pos)) {
 
 		if (zend_hash_get_current_key_ex(Z_ARRVAL_P(params), &key, &key_len, &index, 0, &pos) == HASH_KEY_IS_STRING) {
-			php_protocolbuffers_message_set(INTERNAL_FUNCTION_PARAM_PASSTHRU, instance, container, key, key_len, key, key_len, *param);
+			php_protocolbuffers_message_set(INTERNAL_FUNCTION_PARAM_PASSTHRU, instance, container, key, key_len, key, key_len, *param, strict);
 		}
 	}
 }
@@ -926,9 +929,10 @@ static void php_protocolbuffers_set_from(INTERNAL_FUNCTION_PARAMETERS, zval *ins
 PHP_METHOD(protocolbuffers_message, __construct)
 {
 	zval *params = NULL, *instance = getThis();
+    zend_bool strict = 1;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
-		"|a", &params) == FAILURE) {
+		"|ab", &params, &strict) == FAILURE) {
 		return;
 	}
 
@@ -937,7 +941,7 @@ PHP_METHOD(protocolbuffers_message, __construct)
 	}
 
 	if (params != NULL) {
-		php_protocolbuffers_set_from(INTERNAL_FUNCTION_PARAM_PASSTHRU, instance, params);
+		php_protocolbuffers_set_from(INTERNAL_FUNCTION_PARAM_PASSTHRU, instance, params, strict);
 	}
 }
 /* }}} */
@@ -947,13 +951,14 @@ PHP_METHOD(protocolbuffers_message, __construct)
 PHP_METHOD(protocolbuffers_message, setFrom)
 {
 	zval *params = NULL, *instance = getThis();
+    zend_bool strict = 1;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
-		"a", &params) == FAILURE) {
+		"a|b", &params, &strict) == FAILURE) {
 		return;
 	}
 
-	php_protocolbuffers_set_from(INTERNAL_FUNCTION_PARAM_PASSTHRU, instance, params);
+	php_protocolbuffers_set_from(INTERNAL_FUNCTION_PARAM_PASSTHRU, instance, params, strict);
 }
 /* }}} */
 
@@ -1061,7 +1066,7 @@ PHP_METHOD(protocolbuffers_message, current)
 	}
 
 	if (zend_hash_find(hash, name, name_len, (void **)&tmp) == SUCCESS) {
-		RETVAL_ZVAL(*tmp, 1, 0);
+    	RETVAL_ZVAL(*tmp, 1, 0);
 	}
 }
 /* }}} */
@@ -1219,7 +1224,7 @@ PHP_METHOD(protocolbuffers_message, __call)
 		case MAGICMETHOD_MUTABLE:
 		{
 			php_protocolbuffers_message_get(INTERNAL_FUNCTION_PARAM_PASSTHRU, instance, container, buf.c, buf.len, buf2.c, buf2.len, NULL);
-			php_protocolbuffers_message_set(INTERNAL_FUNCTION_PARAM_PASSTHRU, instance, container, buf.c, buf.len, buf2.c, buf2.len, return_value);
+			php_protocolbuffers_message_set(INTERNAL_FUNCTION_PARAM_PASSTHRU, instance, container, buf.c, buf.len, buf2.c, buf2.len, return_value, 1);
 		}
 		break;
 		case MAGICMETHOD_SET:
@@ -1227,7 +1232,7 @@ PHP_METHOD(protocolbuffers_message, __call)
 			zval **tmp = NULL;
 
 			zend_hash_get_current_data(Z_ARRVAL_P(params), (void **)&tmp);
-			php_protocolbuffers_message_set(INTERNAL_FUNCTION_PARAM_PASSTHRU, instance, container, buf.c, buf.len, buf2.c, buf2.len, *tmp);
+			php_protocolbuffers_message_set(INTERNAL_FUNCTION_PARAM_PASSTHRU, instance, container, buf.c, buf.len, buf2.c, buf2.len, *tmp, 1);
 		}
 		break;
 		case MAGICMETHOD_APPEND:
@@ -1306,7 +1311,7 @@ PHP_METHOD(protocolbuffers_message, mutable)
 	PHP_PROTOCOLBUFFERS_MESSAGE_CHECK_SCHEME
 	php_protocolbuffers_message_get(INTERNAL_FUNCTION_PARAM_PASSTHRU, instance, container, name, name_len, name, name_len, NULL);
 	Z_ADDREF_P(return_value);
-	php_protocolbuffers_message_set(INTERNAL_FUNCTION_PARAM_PASSTHRU, instance, container, name, name_len, name, name_len, return_value);
+	php_protocolbuffers_message_set(INTERNAL_FUNCTION_PARAM_PASSTHRU, instance, container, name, name_len, name, name_len, return_value, 1);
 }
 /* }}} */
 
@@ -1325,7 +1330,7 @@ PHP_METHOD(protocolbuffers_message, set)
 	}
 
 	PHP_PROTOCOLBUFFERS_MESSAGE_CHECK_SCHEME
-	php_protocolbuffers_message_set(INTERNAL_FUNCTION_PARAM_PASSTHRU, instance, container, name, name_len, name, name_len, value);
+	php_protocolbuffers_message_set(INTERNAL_FUNCTION_PARAM_PASSTHRU, instance, container, name, name_len, name, name_len, value, 1);
 }
 
 
@@ -1681,7 +1686,7 @@ PHP_METHOD(protocolbuffers_message, jsonSerialize)
 	if (php_protocolbuffers_jsonserialize(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0, Z_OBJCE_P(instance), instance, &result) == 0) {
 		RETURN_ZVAL(result, 0, 1);
 	}
-	return;
+  return;
 #endif
 }
 /* }}} */
@@ -1695,7 +1700,7 @@ PHP_METHOD(protocolbuffers_message, toArray)
 	if (php_protocolbuffers_jsonserialize(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1, Z_OBJCE_P(instance), instance, &result) == 0) {
 		RETURN_ZVAL(result, 0, 1);
 	}
-	return;
+  return;
 }
 /* }}} */
 
diff --git a/php_protocolbuffers.h b/php_protocolbuffers.h
index c215439..00d7efe 100644
--- a/php_protocolbuffers.h
+++ b/php_protocolbuffers.h
@@ -90,8 +90,7 @@ ZEND_BEGIN_MODULE_GLOBALS(protocolbuffers)
 	HashTable *classes;
 	zval *extension_registry;
 	long strict_mode;
-	long validate_string;
-	long native_scalars;
+	int validate_string;
 ZEND_END_MODULE_GLOBALS(protocolbuffers)
 
 ZEND_EXTERN_MODULE_GLOBALS(protocolbuffers)
diff --git a/protocolbuffers.c b/protocolbuffers.c
index f546ab4..9114d87 100644
--- a/protocolbuffers.c
+++ b/protocolbuffers.c
@@ -280,34 +280,18 @@ PHP_MINFO_FUNCTION(protocolbuffers)
 PHP_INI_BEGIN()
 	STD_PHP_INI_BOOLEAN("protocolbuffers.strict_mode", "1", PHP_INI_ALL, OnUpdateLong, strict_mode, zend_protocolbuffers_globals, protocolbuffers_globals)
 	STD_PHP_INI_BOOLEAN("protocolbuffers.validate_string", "1", PHP_INI_ALL, OnUpdateLong, validate_string, zend_protocolbuffers_globals, protocolbuffers_globals)
-	STD_PHP_INI_BOOLEAN("protocolbuffers.native_scalars", "0", PHP_INI_ALL, OnUpdateLong, native_scalars, zend_protocolbuffers_globals, protocolbuffers_globals)
 PHP_INI_END()
 
 static PHP_GINIT_FUNCTION(protocolbuffers)
-{
-	memset(protocolbuffers_globals, 0, sizeof(zend_protocolbuffers_globals));
-}
-
-static void php_protocolbuffers_cleanup_global_handles(TSRMLS_D)
 {
 }
 
 static PHP_GSHUTDOWN_FUNCTION(protocolbuffers)
 {
-#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 2) || (PHP_MAJOR_VERSION < 5)
-#ifndef ZTS
-	php_protocolbuffers_cleanup_global_handles(TSRMLS_C);
-#endif
-#endif
-}
-
-static void php_protocolbuffers_init_globals() {
-
 }
 
 PHP_MINIT_FUNCTION(protocolbuffers)
 {
-	//ZEND_INIT_MODULE_GLOBALS(protocolbuffers, php_protocolbuffers_init_globals, NULL);
 	REGISTER_INI_ENTRIES();
 
 	php_protocolbuffers_init(TSRMLS_C);
@@ -339,7 +323,6 @@ PHP_RINIT_FUNCTION(protocolbuffers)
 		zend_hash_init(PBG(classes), 0, NULL, NULL, 0);
 	}
 	PBG(validate_string) = 1;
-	PBG(native_scalars) = 0;
 
 	return SUCCESS;
 }
diff --git a/tests/004_decode_bool.phpt b/tests/004_decode_bool.phpt
index 8e0958a..a4f873e 100644
--- a/tests/004_decode_bool.phpt
+++ b/tests/004_decode_bool.phpt
@@ -20,20 +20,5 @@ if ($obj instanceof Tutorial_Boolean) {
 } else {
     var_dump($obj);
 }
-
-ini_set("protocolbuffers.native_scalars", 1);
-$obj = ProtocolBuffers::decode("Tutorial_Boolean", $data);
-
-if ($obj instanceof Tutorial_Boolean) {
-    if ($obj->getValue() === true) {
-        echo "OK" . PHP_EOL;
-    } else {
-        var_dump($obj);
-    }
-} else {
-    var_dump($obj);
-}
-
 --EXPECT--
-OK
 OK
\ No newline at end of file
diff --git a/tests/004_decode_bytes.phpt b/tests/004_decode_bytes.phpt
index cc0dab9..17d0744 100644
--- a/tests/004_decode_bytes.phpt
+++ b/tests/004_decode_bytes.phpt
@@ -18,20 +18,5 @@ if ($obj instanceof Tutorial_Bytes) {
 } else {
     var_dump($obj);
 }
-
-ini_set("protocolbuffers.native_scalars", 1);
-$obj = ProtocolBuffers::decode("Tutorial_Bytes", $bytes);
-
-if ($obj instanceof Tutorial_Bytes) {
-    if ($obj->getValue() === $droid) {
-        echo "OK" . PHP_EOL;
-    } else {
-        var_dump($obj);
-    }
-} else {
-    var_dump($obj);
-}
-
 --EXPECT--
-OK
 OK
\ No newline at end of file
diff --git a/tests/004_decode_double_sample.phpt b/tests/004_decode_double_sample.phpt
index dc808e8..477adc9 100644
--- a/tests/004_decode_double_sample.phpt
+++ b/tests/004_decode_double_sample.phpt
@@ -10,18 +10,7 @@ $obj = ProtocolBuffers::decode("Tutorial_Double", $bytes);
 
 if ($obj instanceof Tutorial_Double) {
     if (round($obj->getValue(), 2) == 1.05) {
-        echo "OK" . PHP_EOL;
-    } else {
-        var_dump($obj);
-    }
-} else {
-    var_dump($obj);
-}
-
-ini_set("protocolbuffers.native_scalars", 1);
-if ($obj instanceof Tutorial_Double) {
-    if (round($obj->getValue(), 2) === 1.05) {
-        echo "OK" . PHP_EOL;
+        echo "OK";
     } else {
         var_dump($obj);
     }
@@ -29,5 +18,4 @@ if ($obj instanceof Tutorial_Double) {
     var_dump($obj);
 }
 --EXPECT--
-OK
 OK
\ No newline at end of file
diff --git a/tests/004_decode_fixed32_init.phpt b/tests/004_decode_fixed32_init.phpt
index 9d52654..a7e3f80 100644
--- a/tests/004_decode_fixed32_init.phpt
+++ b/tests/004_decode_fixed32_init.phpt
@@ -10,26 +10,12 @@ $obj = ProtocolBuffers::decode("Tutorial_Fixed32", $bytes);
 
 if ($obj instanceof Tutorial_Fixed32) {
     if ($obj->getValue() == 0) {
-        echo "OK" . PHP_EOL;
+        echo "OK";
     } else {
         var_dump($obj);
     }
 } else {
     var_dump($obj);
 }
-
-ini_set("protocolbuffers.native_scalars", 1);
-$obj = ProtocolBuffers::decode("Tutorial_Fixed32", $bytes);
-if ($obj instanceof Tutorial_Fixed32) {
-    if ($obj->getValue() === 0) {
-        echo "OK" . PHP_EOL;
-    } else {
-        var_dump($obj);
-    }
-} else {
-    var_dump($obj);
-}
-
 --EXPECT--
-OK
 OK
\ No newline at end of file
diff --git a/tests/004_decode_fixed32_max.phpt b/tests/004_decode_fixed32_max.phpt
index a8ca49e..8b9ad50 100644
--- a/tests/004_decode_fixed32_max.phpt
+++ b/tests/004_decode_fixed32_max.phpt
@@ -13,26 +13,12 @@ $obj = ProtocolBuffers::decode("Tutorial_Fixed32", $bytes);
 
 if ($obj instanceof Tutorial_Fixed32) {
     if ($obj->getValue() == 4294967295) {
-        echo "OK" . PHP_EOL;
+        echo "OK";
     } else {
         var_dump($obj);
     }
 } else {
     var_dump($obj);
 }
-
-ini_set("protocolbuffers.native_scalars", 1);
-$obj = ProtocolBuffers::decode("Tutorial_Fixed32", $bytes);
-if ($obj instanceof Tutorial_Fixed32) {
-    if ($obj->getValue() === 4294967295) {
-        echo "OK" . PHP_EOL;
-    } else {
-        var_dump($obj);
-    }
-} else {
-    var_dump($obj);
-}
-
 --EXPECT--
-OK
 OK
\ No newline at end of file
diff --git a/tests/004_decode_float_sample.phpt b/tests/004_decode_float_sample.phpt
index 90027f5..d649eaf 100644
--- a/tests/004_decode_float_sample.phpt
+++ b/tests/004_decode_float_sample.phpt
@@ -13,26 +13,12 @@ $obj = ProtocolBuffers::decode("Tutorial_Float", $bytes);
 
 if ($obj instanceof Tutorial_Float) {
     if (round($obj->getValue(), 2) == 1.05) {
-        echo "OK" . PHP_EOL;
+        echo "OK";
     } else {
         var_dump($obj);
     }
 } else {
     var_dump($obj);
 }
-
-ini_set("protocolbuffers.native_scalars", 1);
-$obj = ProtocolBuffers::decode("Tutorial_Float", $bytes);
-if ($obj instanceof Tutorial_Float) {
-    if (round($obj->getValue(), 2) === 1.05) {
-        echo "OK" . PHP_EOL;
-    } else {
-        var_dump($obj);
-    }
-} else {
-    var_dump($obj);
-}
-
 --EXPECT--
-OK
 OK
\ No newline at end of file
diff --git a/tests/004_decode_float_signed.phpt b/tests/004_decode_float_signed.phpt
index c774a4f..add9f4e 100644
--- a/tests/004_decode_float_signed.phpt
+++ b/tests/004_decode_float_signed.phpt
@@ -13,26 +13,12 @@ $obj = ProtocolBuffers::decode("Tutorial_Float", $bytes);
 
 if ($obj instanceof Tutorial_Float) {
     if (round($obj->getValue(), 2) == -1.05) {
-        echo "OK" . PHP_EOL;
+        echo "OK";
     } else {
         var_dump($obj);
     }
 } else {
     var_dump($obj);
 }
-
-ini_set("protocolbuffers.native_scalars", 1);
-$obj = ProtocolBuffers::decode("Tutorial_Float", $bytes);
-if ($obj instanceof Tutorial_Float) {
-    if (round($obj->getValue(), 2) === -1.05) {
-        echo "OK" . PHP_EOL;
-    } else {
-        var_dump($obj);
-    }
-} else {
-    var_dump($obj);
-}
-
 --EXPECT--
-OK
 OK
\ No newline at end of file
diff --git a/tests/004_decode_int32_init.phpt b/tests/004_decode_int32_init.phpt
index 09546b4..4b7aa9b 100644
--- a/tests/004_decode_int32_init.phpt
+++ b/tests/004_decode_int32_init.phpt
@@ -13,26 +13,12 @@ $obj = ProtocolBuffers::decode("Tutorial_Integer32", $bytes);
 
 if ($obj instanceof Tutorial_Integer32) {
     if ($obj->getValue() == 0) {
-        echo "OK" . PHP_EOL;
+        echo "OK";
     } else {
         var_dump($obj);
     }
 } else {
     var_dump($obj);
 }
-
-ini_set("protocolbuffers.native_scalars", 1);
-$obj = ProtocolBuffers::decode("Tutorial_Integer32", $bytes);
-if ($obj instanceof Tutorial_Integer32) {
-    if ($obj->getValue() === 0) {
-        echo "OK" . PHP_EOL;
-    } else {
-        var_dump($obj);
-    }
-} else {
-    var_dump($obj);
-}
-
 --EXPECT--
-OK
 OK
\ No newline at end of file
diff --git a/tests/004_decode_int32_max.phpt b/tests/004_decode_int32_max.phpt
index 484d7de..26dee63 100644
--- a/tests/004_decode_int32_max.phpt
+++ b/tests/004_decode_int32_max.phpt
@@ -13,26 +13,12 @@ $obj = ProtocolBuffers::decode("Tutorial_Integer32", $bytes);
 
 if ($obj instanceof Tutorial_Integer32) {
     if ($obj->getValue() == 2147483647) {
-        echo "OK" . PHP_EOL;
+        echo "OK";
     } else {
         var_dump($obj);
     }
 } else {
     var_dump($obj);
 }
-
-ini_set("protocolbuffers.native_scalars", 1);
-$obj = ProtocolBuffers::decode("Tutorial_Integer32", $bytes);
-if ($obj instanceof Tutorial_Integer32) {
-    if ($obj->getValue() === 2147483647) {
-        echo "OK" . PHP_EOL;
-    } else {
-        var_dump($obj);
-    }
-} else {
-    var_dump($obj);
-}
-
 --EXPECT--
-OK
 OK
\ No newline at end of file
diff --git a/tests/004_decode_int32_min.phpt b/tests/004_decode_int32_min.phpt
index ea8da13..6c64d5e 100644
--- a/tests/004_decode_int32_min.phpt
+++ b/tests/004_decode_int32_min.phpt
@@ -13,19 +13,7 @@ $obj = ProtocolBuffers::decode("Tutorial_Integer32", $bytes);
 
 if ($obj instanceof Tutorial_Integer32) {
     if ($obj->getValue() == -2147483648) {
-        echo "OK" . PHP_EOL;
-    } else {
-        var_dump($obj);
-    }
-} else {
-    var_dump($obj);
-}
-
-ini_set("protocolbuffers.native_scalars", 1);
-$obj = ProtocolBuffers::decode("Tutorial_Integer32", $bytes);
-if ($obj instanceof Tutorial_Integer32) {
-    if ($obj->getValue() == -2147483648) {
-        echo "OK" . PHP_EOL;
+        echo "OK";
     } else {
         var_dump($obj);
     }
@@ -33,5 +21,4 @@ if ($obj instanceof Tutorial_Integer32) {
     var_dump($obj);
 }
 --EXPECT--
-OK
 OK
\ No newline at end of file
diff --git a/tests/004_decode_sfixed32_signed.phpt b/tests/004_decode_sfixed32_signed.phpt
index 8f2dac8..3e21578 100644
--- a/tests/004_decode_sfixed32_signed.phpt
+++ b/tests/004_decode_sfixed32_signed.phpt
@@ -13,26 +13,12 @@ $obj = ProtocolBuffers::decode("Tutorial_SFixed32", $bytes);
 
 if ($obj instanceof Tutorial_SFixed32) {
     if ($obj->getValue() == -256) {
-        echo "OK" . PHP_EOL;
+        echo "OK";
     } else {
         var_dump($obj);
     }
 } else {
     var_dump($obj);
 }
-
-ini_set("protocolbuffers.native_scalars", 1);
-$obj = ProtocolBuffers::decode("Tutorial_SFixed32", $bytes);
-if ($obj instanceof Tutorial_SFixed32) {
-    if ($obj->getValue() === -256) {
-        echo "OK" . PHP_EOL;
-    } else {
-        var_dump($obj);
-    }
-} else {
-    var_dump($obj);
-}
-
 --EXPECT--
-OK
 OK
\ No newline at end of file
diff --git a/tests/004_decode_sfixed32_unsigned.phpt b/tests/004_decode_sfixed32_unsigned.phpt
index 854ee68..e36d12d 100644
--- a/tests/004_decode_sfixed32_unsigned.phpt
+++ b/tests/004_decode_sfixed32_unsigned.phpt
@@ -13,26 +13,12 @@ $obj = ProtocolBuffers::decode("Tutorial_SFixed32", $bytes);
 
 if ($obj instanceof Tutorial_SFixed32) {
     if ($obj->getValue() == 256) {
-        echo "OK" . PHP_EOL;
+        echo "OK";
     } else {
         var_dump($obj);
     }
 } else {
     var_dump($obj);
 }
-
-ini_set("protocolbuffers.native_scalars", 1);
-$obj = ProtocolBuffers::decode("Tutorial_SFixed32", $bytes);
-if ($obj instanceof Tutorial_SFixed32) {
-    if ($obj->getValue() === 256) {
-        echo "OK" . PHP_EOL;
-    } else {
-        var_dump($obj);
-    }
-} else {
-    var_dump($obj);
-}
-
 --EXPECT--
-OK
 OK
\ No newline at end of file
diff --git a/tests/004_decode_sint32_init.phpt b/tests/004_decode_sint32_init.phpt
index 6509f7b..b7790c6 100644
--- a/tests/004_decode_sint32_init.phpt
+++ b/tests/004_decode_sint32_init.phpt
@@ -13,26 +13,12 @@ $obj = ProtocolBuffers::decode("Tutorial_SInt32", $bytes);
 
 if ($obj instanceof Tutorial_SInt32) {
     if ($obj->getValue() == 0) {
-        echo "OK" . PHP_EOL;
+        echo "OK";
     } else {
         var_dump($obj);
     }
 } else {
     var_dump($obj);
 }
-
-ini_set("protocolbuffers.native_scalars", 1);
-$obj = ProtocolBuffers::decode("Tutorial_SInt32", $bytes);
-if ($obj instanceof Tutorial_SInt32) {
-    if ($obj->getValue() === 0) {
-        echo "OK" . PHP_EOL;
-    } else {
-        var_dump($obj);
-    }
-} else {
-    var_dump($obj);
-}
-
 --EXPECT--
-OK
 OK
\ No newline at end of file
diff --git a/tests/004_decode_sint32_max.phpt b/tests/004_decode_sint32_max.phpt
index fdf4442..a4f972f 100644
--- a/tests/004_decode_sint32_max.phpt
+++ b/tests/004_decode_sint32_max.phpt
@@ -13,26 +13,12 @@ $obj = ProtocolBuffers::decode("Tutorial_SInt32", $bytes);
 
 if ($obj instanceof Tutorial_SInt32) {
     if ($obj->getValue() == 2147483647) {
-        echo "OK" . PHP_EOL;
+        echo "OK";
     } else {
         var_dump($obj);
     }
 } else {
     var_dump($obj);
 }
-
-ini_set("protocolbuffers.native_scalars", 1);
-$obj = ProtocolBuffers::decode("Tutorial_SInt32", $bytes);
-if ($obj instanceof Tutorial_SInt32) {
-    if ($obj->getValue() === 2147483647) {
-        echo "OK" . PHP_EOL;
-    } else {
-        var_dump($obj);
-    }
-} else {
-    var_dump($obj);
-}
-
 --EXPECT--
-OK
 OK
\ No newline at end of file
diff --git a/tests/004_decode_sint32_min.phpt b/tests/004_decode_sint32_min.phpt
index 4645bff..f9ac53e 100644
--- a/tests/004_decode_sint32_min.phpt
+++ b/tests/004_decode_sint32_min.phpt
@@ -10,28 +10,15 @@ $u = new Tutorial_SInt32();
 $u->setValue(-2147483648);
 
 $obj = ProtocolBuffers::decode("Tutorial_SInt32", $bytes);
-if ($obj instanceof Tutorial_SInt32) {
-    if ($obj->getValue() == -2147483648) {
-        echo "OK" . PHP_EOL;
-    } else {
-        var_dump($obj);
-    }
-} else {
-    var_dump($obj);
-}
 
-ini_set("protocolbuffers.native_scalars", 1);
-$obj = ProtocolBuffers::decode("Tutorial_SInt32", $bytes);
 if ($obj instanceof Tutorial_SInt32) {
-    if ($obj->getValue() === -2147483648) {
-        echo "OK" . PHP_EOL;
+    if ($obj->getValue() == -2147483648) {
+        echo "OK";
     } else {
         var_dump($obj);
     }
 } else {
     var_dump($obj);
 }
-
 --EXPECT--
-OK
 OK
\ No newline at end of file
diff --git a/tests/004_decode_string_0bytes.phpt b/tests/004_decode_string_0bytes.phpt
index 2c82ed7..39b06ca 100644
--- a/tests/004_decode_string_0bytes.phpt
+++ b/tests/004_decode_string_0bytes.phpt
@@ -13,26 +13,12 @@ $obj = ProtocolBuffers::decode("Tutorial_String", $bytes);
 
 if ($obj instanceof Tutorial_String) {
     if ($obj->getValue() === "") {
-        echo "OK" . PHP_EOL;
+        echo "OK";
     } else {
         var_dump($obj);
     }
 } else {
     var_dump($obj);
 }
-
-ini_set("protocolbuffers.native_scalars", 1);
-$obj = ProtocolBuffers::decode("Tutorial_String", $bytes);
-if ($obj instanceof Tutorial_String) {
-    if ($obj->getValue() === "") {
-        echo "OK" . PHP_EOL;
-    } else {
-        var_dump($obj);
-    }
-} else {
-    var_dump($obj);
-}
-
 --EXPECT--
-OK
 OK
\ No newline at end of file
diff --git a/tests/004_decode_string_1024bytes.phpt b/tests/004_decode_string_1024bytes.phpt
index a15745e..aabb7a7 100644
--- a/tests/004_decode_string_1024bytes.phpt
+++ b/tests/004_decode_string_1024bytes.phpt
@@ -10,26 +10,12 @@ $obj = ProtocolBuffers::decode("Tutorial_String", $bytes);
 $expect = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
 if ($obj instanceof Tutorial_String) {
     if ($obj->getValue() === $expect) {
-        echo "OK" . PHP_EOL;
+        echo "OK";
     } else {
         var_dump($obj);
     }
 } else {
     var_dump($obj);
 }
-
-ini_set("protocolbuffers.native_scalars", 1);
-$obj = ProtocolBuffers::decode("Tutorial_String", $bytes);
-if ($obj instanceof Tutorial_String) {
-    if ($obj->getValue() === $expect) {
-        echo "OK" . PHP_EOL;
-    } else {
-        var_dump($obj);
-    }
-} else {
-    var_dump($obj);
-}
-
 --EXPECT--
-OK
 OK
\ No newline at end of file
diff --git a/tests/005_decode_bool_packed.phpt b/tests/005_decode_bool_packed.phpt
index d4b175a..d8bf53d 100644
--- a/tests/005_decode_bool_packed.phpt
+++ b/tests/005_decode_bool_packed.phpt
@@ -19,7 +19,7 @@ if ($obj instanceof Tutorial_Boolean) {
     }
     $values = $obj->getValue();
     if ($values[0] === true && $values[1] === false) {
-        echo "OK" . PHP_EOL;
+        echo "OK";
     } else {
         var_dump($obj);
     }
@@ -27,23 +27,6 @@ if ($obj instanceof Tutorial_Boolean) {
     var_dump($obj);
 }
 
-ini_set("protocolbuffers.native_scalars", 1);
-$obj = ProtocolBuffers::decode("Tutorial_Boolean", $bytes);
-if ($obj instanceof Tutorial_Boolean) {
-    if (count($obj->getValue()) != 2) {
-        var_dump($obj);
-        exit;
-    }
-    $values = $obj->getValue();
-    if ($values[0] === true && $values[1] === false) {
-        echo "OK" . PHP_EOL;
-    } else {
-        var_dump($obj);
-    }
-} else {
-    var_dump($obj);
-}
 
 --EXPECT--
-OK
 OK
\ No newline at end of file
diff --git a/tests/005_decode_double_packed.phpt b/tests/005_decode_double_packed.phpt
index b5bff4b..0d6be97 100644
--- a/tests/005_decode_double_packed.phpt
+++ b/tests/005_decode_double_packed.phpt
@@ -20,24 +20,7 @@ if ($obj instanceof Tutorial_Double) {
     }
     $values = $obj->getValue();
     if ($values[0] == 0 && $values[1] == 1.05 && $values[2] == 3.1418) {
-        echo "OK" . PHP_EOL;
-    } else {
-        var_dump($obj);
-    }
-} else {
-    var_dump($obj);
-}
-
-ini_set("protocolbuffers.native_scalars", 1);
-$obj = ProtocolBuffers::decode("Tutorial_Double", $bytes);
-if ($obj instanceof Tutorial_Double) {
-    if (count($obj->getValue()) != 3) {
-        var_dump($obj);
-        exit;
-    }
-    $values = $obj->getValue();
-    if ($values[0] === 0.0 && $values[1] === 1.05 && $values[2] === 3.1418) {
-        echo "OK" . PHP_EOL;
+        echo "OK";
     } else {
         var_dump($obj);
     }
@@ -46,5 +29,4 @@ if ($obj instanceof Tutorial_Double) {
 }
 
 --EXPECT--
-OK
 OK
\ No newline at end of file
diff --git a/tests/005_decode_fixed32_packed.phpt b/tests/005_decode_fixed32_packed.phpt
index e31eb34..bd1525a 100644
--- a/tests/005_decode_fixed32_packed.phpt
+++ b/tests/005_decode_fixed32_packed.phpt
@@ -22,24 +22,7 @@ if ($obj instanceof Tutorial_Fixed32) {
     }
     $values = $obj->getValue();
     if ($values[0] == 0 && $values[1] == 128 && $values[2] == 256 && $values[3] == 512 && $values[4] == 1024) {
-        echo "OK" . PHP_EOL;
-    } else {
-        var_dump($obj);
-    }
-} else {
-    var_dump($obj);
-}
-
-ini_set("protocolbuffers.native_scalars", 1);
-$obj = ProtocolBuffers::decode("Tutorial_Fixed32", $bytes);
-if ($obj instanceof Tutorial_Fixed32) {
-    if (count($obj->getValue()) != 5) {
-        var_dump($obj);
-        exit;
-    }
-    $values = $obj->getValue();
-    if ($values[0] === 0 && $values[1] === 128 && $values[2] === 256 && $values[3] === 512 && $values[4] === 1024) {
-        echo "OK" . PHP_EOL;
+        echo "OK";
     } else {
         var_dump($obj);
     }
@@ -48,5 +31,4 @@ if ($obj instanceof Tutorial_Fixed32) {
 }
 
 --EXPECT--
-OK
 OK
\ No newline at end of file
diff --git a/tests/005_decode_fixed64_packed.phpt b/tests/005_decode_fixed64_packed.phpt
index fb323a6..a9d532c 100644
--- a/tests/005_decode_fixed64_packed.phpt
+++ b/tests/005_decode_fixed64_packed.phpt
@@ -21,7 +21,7 @@ if ($obj instanceof Tutorial_Fixed64) {
     }
     $values = $obj->getValue();
     if ($values[0] == 0 && $values[1] == 1024) {
-        echo "OK" . PHP_EOL;
+        echo "OK";
     } else {
         var_dump($obj);
     }
@@ -29,23 +29,6 @@ if ($obj instanceof Tutorial_Fixed64) {
     var_dump($obj);
 }
 
-ini_set("protocolbuffers.native_scalars", 1);
-$obj = ProtocolBuffers::decode("Tutorial_Fixed64", $bytes);
-if ($obj instanceof Tutorial_Fixed64) {
-    if (count($obj->getValue()) != 2) {
-        var_dump($obj);
-        exit;
-    }
-    $values = $obj->getValue();
-    if ($values[0] === 0 && $values[1] === 1024) {
-        echo "OK" . PHP_EOL;
-    } else {
-        var_dump($obj);
-    }
-} else {
-    var_dump($obj);
-}
 
 --EXPECT--
-OK
 OK
\ No newline at end of file
diff --git a/tests/005_decode_float_packed.phpt b/tests/005_decode_float_packed.phpt
index f5e3e14..987be1a 100644
--- a/tests/005_decode_float_packed.phpt
+++ b/tests/005_decode_float_packed.phpt
@@ -29,25 +29,7 @@ if ($obj instanceof Tutorial_Float) {
 }
 
 
-ini_set("protocolbuffers.native_scalars", 1);
-$obj = ProtocolBuffers::decode("Tutorial_Float", $bytes);
-if ($obj instanceof Tutorial_Float) {
-    if (count($obj->getValue()) != 3) {
-        var_dump($obj);
-        exit;
-    }
-
-    $values = $obj->getValue();
-    if ($values[0] === 0.0) {
-			echo "OK" . PHP_EOL;
-    }
-} else {
-    var_dump($obj);
-}
-
-
 --EXPECT--
 0
 1.0499999523163
-3.1417999267578
-OK
\ No newline at end of file
+3.1417999267578
\ No newline at end of file
diff --git a/tests/005_decode_int32_packed.phpt b/tests/005_decode_int32_packed.phpt
index ea3c9ac..fd33906 100644
--- a/tests/005_decode_int32_packed.phpt
+++ b/tests/005_decode_int32_packed.phpt
@@ -16,24 +16,7 @@ if ($obj instanceof Tutorial_Integer32) {
     }
     $values = $obj->getValue();
     if ($values[0] == 1) {
-        echo "OK" . PHP_EOL;
-    } else {
-        var_dump($obj);
-    }
-} else {
-    var_dump($obj);
-}
-
-ini_set("protocolbuffers.native_scalars", 1);
-$obj = ProtocolBuffers::decode("Tutorial_Integer32", $bytes);
-if ($obj instanceof Tutorial_Integer32) {
-    if (count($obj->getValue()) != 1) {
-        var_dump($obj);
-        exit;
-    }
-    $values = $obj->getValue();
-    if ($values[0] === 1) {
-        echo "OK" . PHP_EOL;
+        echo "OK";
     } else {
         var_dump($obj);
     }
@@ -42,5 +25,4 @@ if ($obj instanceof Tutorial_Integer32) {
 }
 
 --EXPECT--
-OK
 OK
\ No newline at end of file
diff --git a/tests/005_decode_int32_packed_many.phpt b/tests/005_decode_int32_packed_many.phpt
index 86d9e0d..5ee53a2 100644
--- a/tests/005_decode_int32_packed_many.phpt
+++ b/tests/005_decode_int32_packed_many.phpt
@@ -23,33 +23,7 @@ if ($obj instanceof Tutorial_Integer32) {
     var_dump($obj);
 }
 
-ini_set("protocolbuffers.native_scalars", 1);
-$obj = ProtocolBuffers::decode("Tutorial_Integer32", $bytes);
-if ($obj instanceof Tutorial_Integer32) {
-    if (count($obj->getValue()) != 3) {
-        var_dump($obj);
-        exit;
-    }
-
-    $values = $obj->getValue();
-
-    if ($values[0] === 1) {
-			echo "OK" . PHP_EOL;
-    }
-    if ($values[1] === 2) {
-			echo "OK" . PHP_EOL;
-    }
-    if ($values[2] === 1024) {
-			echo "OK" . PHP_EOL;
-    }
-} else {
-    var_dump($obj);
-}
-
 --EXPECT--
 1
 2
-1024
-OK
-OK
-OK
\ No newline at end of file
+1024
\ No newline at end of file
diff --git a/tests/005_decode_int64_packed.phpt b/tests/005_decode_int64_packed.phpt
index 30b19b7..bd0f1b5 100644
--- a/tests/005_decode_int64_packed.phpt
+++ b/tests/005_decode_int64_packed.phpt
@@ -21,7 +21,7 @@ if ($obj instanceof Tutorial_Integer64) {
     }
     $values = $obj->getValue();
     if ($values[0] == 0 && $values[1] == 1024) {
-        echo "OK" . PHP_EOL;
+        echo "OK";
     } else {
         var_dump($obj);
     }
@@ -29,24 +29,8 @@ if ($obj instanceof Tutorial_Integer64) {
     var_dump($obj);
 }
 
-ini_set("protocolbuffers.native_scalars", 1);
-$obj = ProtocolBuffers::decode("Tutorial_Integer64", $bytes);
-if ($obj instanceof Tutorial_Integer64) {
-    if (count($obj->getValue()) != 2) {
-        var_dump($obj);
-        exit;
-    }
-    $values = $obj->getValue();
-    if ($values[0] === 0 && $values[1] === 1024) {
-        echo "OK" . PHP_EOL;
-    } else {
-        var_dump($obj);
-    }
-} else {
-    var_dump($obj);
-}
+
 
 
 --EXPECT--
-OK
 OK
\ No newline at end of file
diff --git a/tests/005_decode_sfixed32_packed.phpt b/tests/005_decode_sfixed32_packed.phpt
index 5354af8..1390bd1 100644
--- a/tests/005_decode_sfixed32_packed.phpt
+++ b/tests/005_decode_sfixed32_packed.phpt
@@ -20,7 +20,7 @@ if ($obj instanceof Tutorial_SFixed32) {
     }
     $values = $obj->getValue();
     if ($values[0] == -1024 && $values[1] == 0 && $values[2] == 1024) {
-        echo "OK" . PHP_EOL;
+        echo "OK";
     } else {
         var_dump($obj);
     }
@@ -28,23 +28,6 @@ if ($obj instanceof Tutorial_SFixed32) {
     var_dump($obj);
 }
 
-ini_set("protocolbuffers.native_scalars", 1);
-$obj = ProtocolBuffers::decode("Tutorial_SFixed32", $bytes);
-if ($obj instanceof Tutorial_SFixed32) {
-    if (count($obj->getValue()) != 3) {
-        var_dump($obj);
-        exit;
-    }
-    $values = $obj->getValue();
-    if ($values[0] === -1024 && $values[1] === 0 && $values[2] === 1024) {
-        echo "OK" . PHP_EOL;
-    } else {
-        var_dump($obj);
-    }
-} else {
-    var_dump($obj);
-}
 
 --EXPECT--
-OK
 OK
\ No newline at end of file
diff --git a/tests/005_decode_sfixed64_packed.phpt b/tests/005_decode_sfixed64_packed.phpt
index 0014cb2..bbfc191 100644
--- a/tests/005_decode_sfixed64_packed.phpt
+++ b/tests/005_decode_sfixed64_packed.phpt
@@ -23,7 +23,7 @@ if ($obj instanceof Tutorial_SFixed64) {
     $values = $obj->getValue();
 
     if ($values[0] == -1024 && $values[1] == 0 && $values[2] == 1024) {
-        echo "OK" . PHP_EOL;
+        echo "OK";
     } else {
         var_dump($obj);
     }
@@ -31,24 +31,6 @@ if ($obj instanceof Tutorial_SFixed64) {
     var_dump($obj);
 }
 
-ini_set("protocolbuffers.native_scalars", 1);
-$obj = ProtocolBuffers::decode("Tutorial_SFixed64", $bytes);
-if ($obj instanceof Tutorial_SFixed64) {
-    if (count($obj->getValue()) != 3) {
-        var_dump($obj);
-        exit;
-    }
-    $values = $obj->getValue();
-
-    if ($values[0] === -1024 && $values[1] === 0 && $values[2] === 1024) {
-        echo "OK" . PHP_EOL;
-    } else {
-        var_dump($obj);
-    }
-} else {
-    var_dump($obj);
-}
 
 --EXPECT--
-OK
 OK
\ No newline at end of file
diff --git a/tests/005_decode_sint32_packed.phpt b/tests/005_decode_sint32_packed.phpt
index a62f5ac..979de39 100644
--- a/tests/005_decode_sint32_packed.phpt
+++ b/tests/005_decode_sint32_packed.phpt
@@ -20,7 +20,7 @@ if ($obj instanceof Tutorial_SignedInteger32) {
     }
     $values = $obj->getValue();
     if ($values[0] == -1024 && $values[1] == 0 && $values[2] == 1024) {
-        echo "OK" . PHP_EOL;
+        echo "OK";
     } else {
         var_dump($obj);
     }
@@ -28,23 +28,6 @@ if ($obj instanceof Tutorial_SignedInteger32) {
     var_dump($obj);
 }
 
-ini_set("protocolbuffers.native_scalars", 1);
-$obj = ProtocolBuffers::decode("Tutorial_SignedInteger32", $bytes);
-if ($obj instanceof Tutorial_SignedInteger32) {
-    if (count($obj->getValue()) != 3) {
-        var_dump($obj);
-        exit;
-    }
-    $values = $obj->getValue();
-    if ($values[0] === -1024 && $values[1] === 0 && $values[2] === 1024) {
-        echo "OK" . PHP_EOL;
-    } else {
-        var_dump($obj);
-    }
-} else {
-    var_dump($obj);
-}
 
 --EXPECT--
-OK
 OK
\ No newline at end of file
diff --git a/tests/005_decode_sint64_packed.phpt b/tests/005_decode_sint64_packed.phpt
index 0cb92bc..71017ba 100644
--- a/tests/005_decode_sint64_packed.phpt
+++ b/tests/005_decode_sint64_packed.phpt
@@ -17,24 +17,7 @@ if ($obj instanceof Tutorial_SInt64) {
     }
     $values = $obj->getValue();
     if ($values[0] == -1024 && $values[1] == 0 && $values[2] == 1024) {
-        echo "OK" . PHP_EOL;
-    } else {
-        var_dump($obj);
-    }
-} else {
-    var_dump($obj);
-}
-
-ini_set("protocolbuffers.native_scalars", 1);
-$obj = ProtocolBuffers::decode("Tutorial_SInt64", $bytes);
-if ($obj instanceof Tutorial_SInt64) {
-    if (count($obj->getValue()) != 3) {
-        var_dump($obj);
-        exit;
-    }
-    $values = $obj->getValue();
-    if ($values[0] === -1024 && $values[1] === 0 && $values[2] === 1024) {
-        echo "OK" . PHP_EOL;
+        echo "OK";
     } else {
         var_dump($obj);
     }
@@ -44,5 +27,4 @@ if ($obj instanceof Tutorial_SInt64) {
 
 
 --EXPECT--
-OK
 OK
\ No newline at end of file
diff --git a/unknown_field.c b/unknown_field.c
index 2b9288e..fc75529 100644
--- a/unknown_field.c
+++ b/unknown_field.c
@@ -193,7 +193,7 @@ static void php_protocolbuffers_check_type_return(INTERNAL_FUNCTION_PARAMETERS,
 
 }
 
-static void php_protocolbuffers_unknown_field_get_as(INTERNAL_FUNCTION_PARAMETERS, enum WireType type, enum FieldType field_type, int use_string)
+static void php_protocolbuffers_unknown_field_get_as(INTERNAL_FUNCTION_PARAMETERS, enum WireType type, enum FieldType field_type)
 {
 	zval *tmp = NULL, *result = NULL, *instance = getThis();
 	php_protocolbuffers_unknown_field *field = NULL;
@@ -252,7 +252,7 @@ static void php_protocolbuffers_unknown_field_get_as(INTERNAL_FUNCTION_PARAMETER
 				return;
 			}
 
-			php_protocolbuffers_format_string(tmp, &__payload, use_string TSRMLS_CC);
+			php_protocolbuffers_format_string(tmp, &__payload TSRMLS_CC);
 		}
 
 		zend_hash_next_index_insert(Z_ARRVAL_P(result), &tmp, sizeof(zval *), NULL);
@@ -330,7 +330,7 @@ PHP_METHOD(protocolbuffers_unknown_field, getType)
 */
 PHP_METHOD(protocolbuffers_unknown_field, getAsVarintList)
 {
-	php_protocolbuffers_unknown_field_get_as(INTERNAL_FUNCTION_PARAM_PASSTHRU, WIRETYPE_VARINT, -1, PBG(native_scalars));
+	php_protocolbuffers_unknown_field_get_as(INTERNAL_FUNCTION_PARAM_PASSTHRU, WIRETYPE_VARINT, -1);
 }
 /* }}} */
 
@@ -338,7 +338,7 @@ PHP_METHOD(protocolbuffers_unknown_field, getAsVarintList)
 */
 PHP_METHOD(protocolbuffers_unknown_field, getAsLengthDelimitedList)
 {
-	php_protocolbuffers_unknown_field_get_as(INTERNAL_FUNCTION_PARAM_PASSTHRU, WIRETYPE_LENGTH_DELIMITED, -1, PBG(native_scalars));
+	php_protocolbuffers_unknown_field_get_as(INTERNAL_FUNCTION_PARAM_PASSTHRU, WIRETYPE_LENGTH_DELIMITED, -1);
 }
 /* }}} */
 
@@ -346,7 +346,7 @@ PHP_METHOD(protocolbuffers_unknown_field, getAsLengthDelimitedList)
 */
 PHP_METHOD(protocolbuffers_unknown_field, getAsFixed32List)
 {
-	php_protocolbuffers_unknown_field_get_as(INTERNAL_FUNCTION_PARAM_PASSTHRU, WIRETYPE_FIXED32, -1, PBG(native_scalars));
+	php_protocolbuffers_unknown_field_get_as(INTERNAL_FUNCTION_PARAM_PASSTHRU, WIRETYPE_FIXED32, -1);
 }
 /* }}} */
 
@@ -354,7 +354,7 @@ PHP_METHOD(protocolbuffers_unknown_field, getAsFixed32List)
 */
 PHP_METHOD(protocolbuffers_unknown_field, getAsFixed64List)
 {
-	php_protocolbuffers_unknown_field_get_as(INTERNAL_FUNCTION_PARAM_PASSTHRU, WIRETYPE_FIXED64, -1, PBG(native_scalars));
+	php_protocolbuffers_unknown_field_get_as(INTERNAL_FUNCTION_PARAM_PASSTHRU, WIRETYPE_FIXED64, -1);
 }
 /* }}} */
 
@@ -362,7 +362,7 @@ PHP_METHOD(protocolbuffers_unknown_field, getAsFixed64List)
 */
 PHP_METHOD(protocolbuffers_unknown_field, getAsFloatList)
 {
-	php_protocolbuffers_unknown_field_get_as(INTERNAL_FUNCTION_PARAM_PASSTHRU, WIRETYPE_FIXED32, TYPE_FLOAT, PBG(native_scalars));
+	php_protocolbuffers_unknown_field_get_as(INTERNAL_FUNCTION_PARAM_PASSTHRU, WIRETYPE_FIXED32, TYPE_FLOAT);
 }
 /* }}} */
 
@@ -370,7 +370,7 @@ PHP_METHOD(protocolbuffers_unknown_field, getAsFloatList)
 */
 PHP_METHOD(protocolbuffers_unknown_field, getAsDoubleList)
 {
-	php_protocolbuffers_unknown_field_get_as(INTERNAL_FUNCTION_PARAM_PASSTHRU, WIRETYPE_FIXED64, TYPE_DOUBLE, PBG(native_scalars));
+	php_protocolbuffers_unknown_field_get_as(INTERNAL_FUNCTION_PARAM_PASSTHRU, WIRETYPE_FIXED64, TYPE_DOUBLE);
 }
 /* }}} */
 

From 8438140eb486e3c19493008e37ec299fd8b77deb Mon Sep 17 00:00:00 2001
From: hellofreedom <liudezhiabc@126.com>
Date: Tue, 28 Apr 2015 11:53:15 +0800
Subject: [PATCH 3/4] 0.2.6.2

---
 .travis.yml                                   |  16 -
 Rakefile                                      |  48 --
 contents/php-protocolbuffers.png              | Bin 3379 -> 0 bytes
 examples/Json.md                              |  58 ---
 examples/README.md                            |   6 -
 examples/addressbook.php                      |  51 --
 examples/addressbook.proto                    |  24 -
 examples/extension.php                        |  53 --
 examples/misc/address.php                     |  24 -
 examples/misc/address2.php                    |  24 -
 examples/misc/address3.php                    |  24 -
 examples/misc/address4.php                    |  24 -
 examples/misc/address5.php                    |  20 -
 examples/misc/reflection.php                  |  23 -
 examples/php/addressbook.proto.php            | 181 -------
 examples/php/prefecture.proto.php             | 137 -----
 examples/prefecture.php                       |  45 --
 examples/prefecture.proto                     |  13 -
 examples/prefecture.tsv                       |  47 --
 examples/uv/README.md                         |  46 --
 examples/uv/client.php                        |  60 ---
 examples/uv/message.proto                     |  36 --
 examples/uv/proto/message.proto.php           | 265 ----------
 examples/uv/server.php                        |  94 ----
 package.xml                                   | 365 --------------
 ...no41_constructor_should_accept_object.phpt | 170 -------
 tests/conformance/CmakeLists.txt              |  89 ----
 tests/conformance/conformance_test.cc         |  80 ---
 tests/conformance/proto/message_sint32.proto  |  27 -
 tests/integration/README.md                   |  10 -
 tests/integration/bootstrap.php               |  45 --
 tests/integration/composer.json               |   9 -
 tests/integration/composer.lock               | 477 ------------------
 tests/integration/messages/autoload.php       |  18 -
 .../messages/pecl/protocolbuffers/User.php    |  78 ---
 .../integration/messages/proto/user.proto.php |   2 -
 tests/integration/php-fpm.conf                |  13 -
 tests/integration/phpunit.xml.dist            |  25 -
 tests/integration/proto/user.proto            |   7 -
 tests/integration/protocolbuffers.ini         |   1 -
 tests/integration/src/MultipleRequest.php     |   7 -
 tests/integration/test.php                    |   2 -
 .../integration/tests/MultipleRequestTest.php |  17 -
 43 files changed, 2761 deletions(-)
 delete mode 100644 .travis.yml
 delete mode 100644 Rakefile
 delete mode 100644 contents/php-protocolbuffers.png
 delete mode 100644 examples/Json.md
 delete mode 100644 examples/README.md
 delete mode 100644 examples/addressbook.php
 delete mode 100644 examples/addressbook.proto
 delete mode 100644 examples/extension.php
 delete mode 100644 examples/misc/address.php
 delete mode 100644 examples/misc/address2.php
 delete mode 100644 examples/misc/address3.php
 delete mode 100644 examples/misc/address4.php
 delete mode 100644 examples/misc/address5.php
 delete mode 100644 examples/misc/reflection.php
 delete mode 100644 examples/php/addressbook.proto.php
 delete mode 100644 examples/php/prefecture.proto.php
 delete mode 100644 examples/prefecture.php
 delete mode 100644 examples/prefecture.proto
 delete mode 100644 examples/prefecture.tsv
 delete mode 100644 examples/uv/README.md
 delete mode 100644 examples/uv/client.php
 delete mode 100644 examples/uv/message.proto
 delete mode 100644 examples/uv/proto/message.proto.php
 delete mode 100644 examples/uv/server.php
 delete mode 100644 package.xml
 delete mode 100644 tests/999_no41_constructor_should_accept_object.phpt
 delete mode 100644 tests/conformance/CmakeLists.txt
 delete mode 100644 tests/conformance/conformance_test.cc
 delete mode 100644 tests/conformance/proto/message_sint32.proto
 delete mode 100644 tests/integration/README.md
 delete mode 100644 tests/integration/bootstrap.php
 delete mode 100644 tests/integration/composer.json
 delete mode 100644 tests/integration/composer.lock
 delete mode 100644 tests/integration/messages/autoload.php
 delete mode 100644 tests/integration/messages/pecl/protocolbuffers/User.php
 delete mode 100644 tests/integration/messages/proto/user.proto.php
 delete mode 100644 tests/integration/php-fpm.conf
 delete mode 100644 tests/integration/phpunit.xml.dist
 delete mode 100644 tests/integration/proto/user.proto
 delete mode 100644 tests/integration/protocolbuffers.ini
 delete mode 100644 tests/integration/src/MultipleRequest.php
 delete mode 100644 tests/integration/test.php
 delete mode 100644 tests/integration/tests/MultipleRequestTest.php

diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 105e4f2..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,16 +0,0 @@
-language: php
-php:
-  - 5.2
-  - 5.3
-  - 5.4
-  - 5.5
-
-script:
-  - uname -a
-  - cat /etc/issue
-  - rake compile test
-  - rake integration
-
-notifications:
-  irc: "chat.freenode.net#php-protocolbuffers"
-  use_notice: true
diff --git a/Rakefile b/Rakefile
deleted file mode 100644
index 89a4c91..0000000
--- a/Rakefile
+++ /dev/null
@@ -1,48 +0,0 @@
-if File.exists?(".Rakefile") 
-  import ".Rakefile"
-end
-
-def cmd_run(command)
-  print "\#execute #{command}...\n"
-  IO.popen(command) {|pipe|
-    pipe.each { |line|
-      print "+ " + line
-    }
-    $?.to_i
-  }
-end
-
-task :package do
-  cmd_run('php -ddate.timezone="Asia/Tokyo" pyrus.phar pickle -n protocolbuffers pecl.php.net php-protocolbuffers')
-end
-
-task :compile do
-  cmd_run("phpize")
-  cmd_run("./configure")
-  cmd_run("make")
-end
-
-task :install do
-  cmd_run("make install")
-end
-
-desc "run php test cases"
-task :test do
-  ENV["TESTS"] = "--show-diff -q"
-  cmd_run("make test")
-  sh "cat tests/*.diff; if [ $? -eq 0 ];then exit 1; fi"
-end
-
-task :integration do
-  if ENV["TRAVIS_PHP_VERSION"].to_f >= 5.3 then
-    sh "phpenv config-add tests/integration/protocolbuffers.ini"
-    sh "sudo make install"
-    sh "sudo cp tests/integration/php-fpm.conf ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf"
-    sh "sudo ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm"
-
-    Dir.chdir("tests/integration") do
-      cmd_run("composer install --no-interaction")
-      cmd_run("./vendor/bin/phpunit")
-    end
-  end
-end
\ No newline at end of file
diff --git a/contents/php-protocolbuffers.png b/contents/php-protocolbuffers.png
deleted file mode 100644
index 0a15c7d7e86d339edd4fe57c2b1b66d64f4d39fa..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 3379
zcmZu!X*?8M7Z<W7X-FnZ#u~!d#x!cgATpaRv<%8JWSb_kN20NlU3Mc|mPT2#MA^fT
zM3zVPOo)auc*pa6eLviL?mfSA&pE&US?;|g49bX)2gt+1!op{K4PnN@!ir$7uXC|6
z=i(igWF}#Ipl58s#l<!G4|<llRmYfG7%=Jj`Z^AWYi(_nkdTOvkB7tI{r&wRAt6;&
zRfmU%{QUfAG<s%cMqOP!H#gVQ)AMn(p&;`Zx7RhB2P`Z?`$yy0fEU)D$rL3TSQE`X
zoru2n1V@&u_dFdO&l}<ij=r7*w+H9-&9#=BU&k=z&K$|<6CCY{cu$Y>7I=3@7O<L%
znuZEkUDev`91F_{q%q>E#iJLr+dsm7$a8u8G=A`74^Gn(7Cf#b>(ux_b|!Z!KkOP7
zTfMZ|?EPI@e8y__<9Zhj0YQEDDLD7i8#Wv}QlGv25&sQE{I204*XRwb159bhPLe!c
zeDs!6hzfUQNMf4EukT^s@H*jMAkYzPD2-3<cXr~t-aY$ZzZTd;uANU;3G*4Xq?2+^
zb8Zh_E!>`9j69<GWSx-7mx0YI@MiLF7irHTepjM%?qr1kM?F@QZ0ak2EyIUK<{kq=
z^(_6}5ActtZ1te-Jr&z89JxjSQqv?LW*Ndc_8m4Z8d87V0b&A;>fI9Zx=zYDyNMbN
z)l2Ji`BLcjc>%Hwfkk^y6H~W^MY)2c{T(`C*rp#32I&5mTgY%4BtzE8IAGKrW@=b~
zK*v6k1L{`s*8brh#Zhx7E@sF$Z>0F`H7&p29)0EuvIb2KA`jDcQx8U_*P}5gH`X*x
za#9X(6E*L*Q`J$o9T}{s2Yp2%T5g!9frnA|<~rOQYWp@X?yux)Wy_xL#!;pHT@kRv
zug+CNi=3Ds;}F-nd#TBlJk;Bgfx33=HZ^VV;H17iGIpc)X<A_?crm5a&RH9IrNpMj
zP>=VIx^`4bxSC{5WCcQn|NS-}GBEPHmd@PsIKY70+q&C8O%*O(&NNQ?*WW)W0kn4e
zsm@-3{JY9!H>Rrkh-38Kj{D+kwC>sPbLIDTtM9wRb8Xytv!WHYpaEqKEBU7klx{1Z
zs9l~|u;mrVnnPyTMFP_#ALn&lDe@6qff?>jpMmWv%ch^<e^)hmGIq+lAV``<0q?7L
zonTFxj`a$z_XI6G8&X9NIf=;Ksr&*5|Bbum11`6Q>|VrFZzg7m^MwBM`BGGVs2Uc4
zp>H$?dAT6|MtOVnpt_~g-{ya$uyvx6Lov9gVQ>9v-%L71J(mI*l3dYd=M+`--xxiQ
z38r(|_P{>hd*02+m?TaMM9C+UW*8efOYF&NLG5ek;}xZL6A>HQIk6l(ap<$I6SC6g
zQbvfF(_25gXAzV^3TUVPR*ChEEi(x<;kMj{l>(40Rn{2KSaddVMd>P!9KTJol}=B+
z*-4wN1|$-*L#GaR9}=z#$ry!4eDwsREAuu!o;Usw)rw``Z4~-O#3pjOW@>M~yc^6l
zXmemwe7!L)$tnvE?b3e^gb6fpRLTpwS3uMkWeEtE<PF$(mws9lpQA3J(jjP0C;51|
zN^S$25MIzJPwRmF(La72znnq)7b>tm$7hj!d_&XCFx0#eH1$ow#QCAbi1}yQ1)W-E
zI;37;eA9EwDvOF~-z%T9DuNCa>X}-8>1G6otLUtYpODRngI~Z+-RH36wRM+B-*_c4
z?c8ktYWYK-k`E}-589IH-efmfLF+#pwk=N(6);M65o3e@r7cgT{9O9+fh*z8UW!q%
zL(t^#8tb0Bp;c{lU*O_N%c6H!t7ua-%wi6w{2s9Wj&kS@@@WG(X<2KfDL{QUWWdGo
zw@g$sC$2E-*gV3eJz}dAuH>7&wsq3m63hf3{arSB`ikm<`@IYwpS?xJRl$m4?pJ)H
zMA4FKZ2PppNG;g|joURDr!N%t4<jX>>_Oyvvr_9bIp+~R<Z^Xm=UP<iWNqQ%aJN9d
zz0W628KrV4Equ&&<Dngo6+m%l5{K*}V!_E77$CaZGIt>P)YW5+0;-Ml$I6dJ!XVe7
z+C_2RffP^kY-HAH3-u`{Fd=HJLsBNyJHuljTSW|ul=tus4@(hGb~wV*3P5;V=q;E=
zNpzCGzQds2x~VJNjJHQ6zh41D6Y;<ykqOgI$6k5pybA%rEjQ_4h0xesHtDn~!du5W
z2C=PP8nY-$3=Ojj@O$6zIvMM<;=yfh9|jr9)_g@qF|5KG^DNCRoErzJnm42(;kXMK
z`N;UbPYw5_vU~3{^6dDeJ1xcB6sU|)was&vxB5gJQ%{0sQ0i86j+#i#P|b^XatR*b
z_d9VgCHQBN3z9%7!?<A@mpUBt@t(wLn_vZTB<_cGAqkEFwhn*mF`ssUHg5L)S-7>&
zzD*pTUe0KHMq<Q%H_v7hxeAovm`~`drgKp!3aZEZLN8TYkLe=c72hr6CMSG|qxX#Y
zc$Gg#IIqVK38v;efu1uGkv|STR^c7Es;1FRo^qW}XcrXduN`28BLWHL8SxT=6``5_
z$ga#NjXB9$G-|&jO5+ONQF93y?b%~>V!CU)AE2!qt`>$RblbgV>;K8ko0(5CdZ{J>
zm$$~70zPlPjMC_m)y)ecc<vM`P@91XNaNavo5ewQi2#W^kCBw1?Rs5)h=!E5L5~1>
z7i^+k&RU1<iKIxT3S|xn7nQ{=L}`?BZ=O1(1CYHX-uCn!D7z<gVZ4WRu=JbX49qQ&
zrvHh)5T&J`EGhtWqKALD*hy5NY(5Fo+#ufi47SWLV}x>0FOR2?acAsT`1yl=R^sxP
zED8Z<p)+J}5TLEM>$pF7kXW851v25Lhd-6VQ4=mtxmdID=V*#?Do`)IXBXEil-24_
z)Uu8HnWD-^k@#C({AR5?_5~mUo5)dZv7~FL>h(DK5%Cl`oT8%63(oEhJPN$%Ck-)9
zHHabL_4x2^_&aBo%+_H7(c;YLQVVB||6jhf&q*V~4E`zoeVu4!sggt~y^j9e>e(g)
zKqWzi<oMrt1*$wCuudAIy2tI~h%a<paZ;{j1RgM6^rrecl>K3&V=^<Bxn+_CMvuyA
z5p8WZo0@cGUoC?Pz^u&(6992xj@DRV`4}zp@Xu*lwyB>uUK(g?E`{cN%<U$Xe1`{`
zoR>PQ?W0OSh?=vS({|lghWxB{vq(Z3Vv501?%NsPN=n;$4A*+8`7g-oCtF9&;t!TW
z0hsn4P1L-bi?Fi4C0acUiU%Yy+dQ|gr7Gn7V$%4xc;gzkeCOYX9%ZGY512SE>xTB!
z&tU{r>QLfMuZi-`D=h%p`rm8R4o&wb@sic9+KQ~&iC^{07ocud&1+(0(LJ!UT<lR)
zB~9yO%BnyCaoO1orWxCe{>J7=ZB#o?c&T5ULDRdr5npEO32=Y-%qK6xIN0iYj7~9V
zpfYoyX%M>OX3aiwGCsJ($Lv_tB}LY8z3wud>cQh`VWtL|O3drPrapgRbs5s1{IKi#
zKyQ$C*-<BFr!C1wDpHGB{eCItSK`|}SAm<bCCJdVV4izZX3vkX_BJKug?c3{hp3P<
zQvzt1k_Kj?h9xbYz@O7tWmd_i2x<fLBnUc3enCGZ*rW)_cNcKpo_J*#_w23-`^VKQ
z>$0Axa~BnN$b+kKrM+_xBw;q}HSqu;e8Jtfk|VFzzkhqm?{7a-3iskJtOOyYj(jzJ
z`nn1eKsP+Cs~jma7UQ@1r3{v;NDZ7_k2uQ~6I2gET5BSop7ONya0+l}Cxv7AzAeZP
zaJ5{^VqOnmlOc-umZSeyrx4i)Mw_D}&?28-%%itGp5jaa!+r^zp%x0^(eyuV_(L*B
z*%GVM!LH)_Cy@2&agh|+|MFAxuMllG%LULd){gT%1WH-+`r6Bbw>Uiv7itRJ^k)2V
zd=p#6JeS)#4n)io->%NlZ!Yc{xjh=uYG{>hVF=m#g6>Wo8>{s%X;%Mp@B_6AiQ`$~
z&NGX9_Qd3TjQhJR&$%WsNOZDh!|q}CrKOFVrhW#5>yjQ<7o0o>+`iUb>DS5n68|z#
zTnt)&^B{mfH9Wc_0Xb>W&>%J&LxBmb<vWKg?<T*nFky(L!xFJZtz1n2@?Y;Ib3)5+
z-jP;eYVF=XEA_C%mU+1tbAs80P2aZWtP@m~_lt;cY|T>IGIA-WLpYtjlo7YftD)Gk
zT#G9*OLd2O^uZ3%EJLw<h5IOJ%Yd%Ae@%#_D;ZW6;v#703P0F&d6}RTWDa=N$T#u}
zaFGL~bk0YS|M9r)6E5BuR_R<sl(N?RYxRbmLgdpdkKAA}D>;+jDukS*Ei{9Y2amc;
zms~nU3KltHuU})bCl76gRP17d(|H9*!9rGY6N3i(Uz<w*)sm*l+X5Os^8I%??erSx
t<$RIZ9NPX&pg{rd$)4Hb|9|g?$RWk_e`F}lFuxuw#s(-vrJh~b{{R+oUP1r>

diff --git a/examples/Json.md b/examples/Json.md
deleted file mode 100644
index 7fd05b0..0000000
--- a/examples/Json.md
+++ /dev/null
@@ -1,58 +0,0 @@
-# JsonSerialize specification
-
-## Types
-
-Basically, json serialize implementation respects protocol buffers serialization rule.
-
-| PB Type     | Json Type |
-|-------------|-----------|
-|TYPE_DOUBLE  | NUMBER    |
-|TYPE_FLOAT   | NUMBER    |
-|TYPE_INT64   | NUMBER    |
-|TYPE_UINT64  | NUMBER    |
-|TYPE_INT32   | NUMBER    |
-|TYPE_FIXED64 | NUMBER    |
-|TYPE_FIXED32 | NUMBER    |
-|TYPE_BOOL    | BOOLEAN   |
-|TYPE_STRING  | STRING    |
-|TYPE_BYTES   | STRING    |
-|TYPE_UINT32  | NUMBER    |
-|TYPE_ENUM    | NUMBER    |
-|TYPE_SFIXED32| NUMBER    |
-|TYPE_SFIXED64| NUMBER    |
-|TYPE_SINT32  | NUMBER    |
-|TYPE_SINT64  | NUMBER    |
-|TYPE_MESSAGE | OBJECT    |
-
-* JsonSerialize does not serialize NULL value.
-* JsonSerialize uses original field name (same as proto file) as property key.
-* JsonSerialize might loose precision when using big number. this is PHP limitation.
-
-### Errors
-
-* jsonSerialize method doesn't use exceptions.
-
-## Unknown Field
-
-* does not support.
-
-## Extensions
-
-* supported
-
-## Overriding
-
-`jsonSerialize` method can override. you can filter needless values with overriding jsonSerialize method.
-
-```
-public function jsonSerialize()
-{
-    $array = parent::jsonSerialize(); // also you can use toArray() method.
-    return $this->filter_needless_values($array);
-}
-
-```
-
-## Others
-
-* `__sleep` and `__wakeup` method doesn't invoke when serializing json.
diff --git a/examples/README.md b/examples/README.md
deleted file mode 100644
index 822d627..0000000
--- a/examples/README.md
+++ /dev/null
@@ -1,6 +0,0 @@
-# Protocol Buffers Examples
-
-````
-# generate message classes from .proto file
-protoc --plugin=../contrib/protoc-gen-php addressbook.proto --php_out=php -I . -I /usr/local/include
-````
diff --git a/examples/addressbook.php b/examples/addressbook.php
deleted file mode 100644
index 31f8652..0000000
--- a/examples/addressbook.php
+++ /dev/null
@@ -1,51 +0,0 @@
-<?php
-require dirname(__FILE__) . DIRECTORY_SEPARATOR . join(DIRECTORY_SEPARATOR, array("php", "addressbook.proto.php"));
-
-$db = "addressbook.db";
-
-$addressbook = load($db);
-$person = new Tutorial_Person();
-$person->setId(1);
-$person->setName("John Doe");
-$person->setEmail("john.doe@example.com");
-
-$phone = new Tutorial_Person_PhoneNumber();
-$phone->setNumber("1234 5 67 78");
-$phone->setType(Tutorial_Person_PhoneType::HOME);
-$person->appendPhone($phone);
-
-
-$phone = new Tutorial_Person_PhoneNumber();
-$phone->setNumber("1234 5 67 79");
-$phone->setType(Tutorial_Person_PhoneType::HOME);
-$person->appendPhone($phone);
-
-echo $person;
-exit;
-echo "____________________\n";
-
-$addressbook->appendPerson($person);
-
-
-var_dump($addressbook);
-
-save($db, $addressbook);
-
-exit;
-
-function load($path)
-{
-    $data = @file_get_contents($path);
-    try {
-        $result = ProtocolBuffers::decode("Tutorial_AddressBook", $data);
-    } catch (ProtocolBuffersInvalidProtocolBufferException $e) {
-        $result = new Tutorial_AddressBook();
-    }
-
-    return $result;
-}
-
-function save($path, Tutorial_AddressBook $addresbook)
-{
-    file_put_contents($path, $addresbook->serializeToString());
-}
diff --git a/examples/addressbook.proto b/examples/addressbook.proto
deleted file mode 100644
index 8eb134b..0000000
--- a/examples/addressbook.proto
+++ /dev/null
@@ -1,24 +0,0 @@
-package Tutorial;
-
-message Person {
-	required string name = 1;
-	required int32 id = 2;
-	optional string email = 3;
-
-	enum PhoneType {
-		MOBILE = 0;
-		HOME = 1;
-		WORK = 2;
-	}
-
-	message PhoneNumber {
-		required string number = 1;
-		optional PhoneType type = 2 [default = HOME];
-	}
-
-	repeated PhoneNumber phone = 4;
-}
-
-message AddressBook {
-	repeated Person person = 1;
-}
diff --git a/examples/extension.php b/examples/extension.php
deleted file mode 100644
index d94f571..0000000
--- a/examples/extension.php
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-class Person extends ProtocolBuffersMessage
-{
-    protected $value;
-
-    /**
-     * get descriptor for protocol buffers
-     *
-     * @return array
-     */
-    public static function getDescriptor()
-    {
-        static $descriptor;
-
-        if (!isset($descriptor)) {
-            $desc = new ProtocolBuffersDescriptorBuilder();
-            $desc->addField(1, new ProtocolBuffersFieldDescriptor(array(
-                "type"     => ProtocolBuffers::TYPE_INT32,
-                "name"     => "value",
-                "required" => false,
-                "optional" => false,
-                "repeated" => false,
-                "packable" => false,
-                "default"  => null,
-                "message"  => "Tutorial_Person",
-            )));
-            $desc->addExtensionRange(200, 500);
-            $desc->addExtensionRange(600, 700);
-            $descriptor = $desc->build();
-            $descriptor->dump();
-        }
-
-        return $descriptor;
-    }
-}
-$registry = ProtocolBuffersExtensionRegistry::getInstance();
-
-// You can extend Person message like this. (normally we generate these code from .proto. adding by hand is bad idea.)
-$registry->add("Person", 256, new ProtocolBuffersFieldDescriptor(array(
-    "type"     => ProtocolBuffers::TYPE_INT32,
-    "name"     => "address",
-    "required" => false,
-    "optional" => false,
-    "repeated" => false,
-    "packable" => false,
-    "default"  => null,
-)));
-
-$p = new Person();
-$p->setExtension("address", 256);
-$p2 = ProtocolBuffers::decode("Person", $p->serializeToString());
-
-var_dump($p2);
diff --git a/examples/misc/address.php b/examples/misc/address.php
deleted file mode 100644
index edeb225..0000000
--- a/examples/misc/address.php
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-require dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . "contrib/php/addressbook.proto.php";
-
-$person = new Tutorial_Person();
-$person->setId(21);
-$person->setName("John Doe");
-
-$data = ProtocolBuffers::encode($person);
-
-printf("# decoding benchmark (protocolbuffers).\n");
-printf("# target message size: %d bytes.\n", strlen($data));
-printf("# start\n");
-
-$begin = microtime(true);
-$attempts = 100000;
-for ($i = 0; $i < $attempts; $i++) {
-    ProtocolBuffers::decode("Tutorial_Person", $data);
-}
-$end = microtime(true);
-
-printf("# Result:\n");
-printf("# decoding %d messages\n", $attempts);
-printf("# processing time: %6f (%f/message)\n", $end - $begin, ($end - $begin) / $attempts);
-printf("# total bytes: %d bytes\n", strlen($data) * $attempts);
diff --git a/examples/misc/address2.php b/examples/misc/address2.php
deleted file mode 100644
index 92193af..0000000
--- a/examples/misc/address2.php
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-require dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . "contrib/php/addressbook.proto.php";
-
-$person = new Tutorial_Person();
-$person->setId(21);
-$person->setName("John Doe");
-
-$data = serialize($person);
-
-printf("# decoding benchmark (serialize / unserialize).\n");
-printf("# target message size: %d bytes.\n", strlen($data));
-printf("# start\n");
-
-$begin = microtime(true);
-$attempts = 100000;
-for ($i = 0; $i < $attempts; $i++) {
-    unserialize($data);
-}
-$end = microtime(true);
-
-printf("# Result:\n");
-printf("# decoding %d messages\n", $attempts);
-printf("# processing time: %6f (%f/message)\n", $end - $begin, ($end - $begin) / $attempts);
-printf("# total bytes: %d bytes\n", strlen($data) * $attempts);
diff --git a/examples/misc/address3.php b/examples/misc/address3.php
deleted file mode 100644
index 05daf1a..0000000
--- a/examples/misc/address3.php
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-require dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . "contrib/php/addressbook.proto.php";
-
-$person = new Tutorial_Person();
-$person->setId(21);
-$person->setName("John Doe");
-
-$data = $person->serializeToString($person);
-
-printf("# decoding benchmark (protocolbuffers).\n");
-printf("# target message size: %d bytes.\n", strlen($data));
-printf("# start\n");
-
-$begin = microtime(true);
-$attempts = 100000;
-for ($i = 0; $i < $attempts; $i++) {
-    Tutorial_Person::parseFromString($data);
-}
-$end = microtime(true);
-
-printf("# Result:\n");
-printf("# decoding %d messages\n", $attempts);
-printf("# processing time: %6f (%f/message)\n", $end - $begin, ($end - $begin) / $attempts);
-printf("# total bytes: %d bytes\n", strlen($data) * $attempts);
diff --git a/examples/misc/address4.php b/examples/misc/address4.php
deleted file mode 100644
index cf567c1..0000000
--- a/examples/misc/address4.php
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-require dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . "contrib/php/addressbook.proto.php";
-
-$person = new Tutorial_Person();
-$person->setId(21);
-$person->setName("John Doe");
-
-$data = msgpack_pack($person);
-
-printf("# decoding benchmark (msgpack).\n");
-printf("# target message size: %d bytes.\n", strlen($data));
-printf("# start\n");
-
-$begin = microtime(true);
-$attempts = 100000;
-for ($i = 0; $i < $attempts; $i++) {
-    msgpack_unpack($data);
-}
-$end = microtime(true);
-
-printf("# Result:\n");
-printf("# decoding %d messages\n", $attempts);
-printf("# processing time: %6f (%f/message)\n", $end - $begin, ($end - $begin) / $attempts);
-printf("# total bytes: %d bytes\n", strlen($data) * $attempts);
diff --git a/examples/misc/address5.php b/examples/misc/address5.php
deleted file mode 100644
index b999bc1..0000000
--- a/examples/misc/address5.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-require dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . "contrib/php/addressbook.proto.php";
-
-$data = msgpack_pack(array("id" => 21, "name" => "John Doe"));
-
-printf("# decoding benchmark (msgpack array).\n");
-printf("# target message size: %d bytes.\n", strlen($data));
-printf("# start\n");
-
-$begin = microtime(true);
-$attempts = 100000;
-for ($i = 0; $i < $attempts; $i++) {
-    msgpack_unpack($data);
-}
-$end = microtime(true);
-
-printf("# Result:\n");
-printf("# decoding %d messages\n", $attempts);
-printf("# processing time: %6f (%f/message)\n", $end - $begin, ($end - $begin) / $attempts);
-printf("# total bytes: %d bytes\n", strlen($data) * $attempts);
diff --git a/examples/misc/reflection.php b/examples/misc/reflection.php
deleted file mode 100644
index 339f439..0000000
--- a/examples/misc/reflection.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-require dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . "contrib/php/addressbook.proto.php";
-
-// example: ProtocolBuffers to Json format
-
-$person = new Tutorial_Person();
-$person->setId(21);
-$person->setName("John Doe");
-
-$descriptor = $person->getDescriptor();
-$result = array();
-
-foreach ($descriptor->getFields() as $field) {
-    if (!$field->isExtension()) {
-        if ($person->has($field->getName())) {
-            // this does not care about Message.
-            $value = $person->get($field->getName());
-            $result[$field->getName()] = $value;
-        }
-    }
-}
-
-echo json_encode($result, JSON_PRETTY_PRINT);
diff --git a/examples/php/addressbook.proto.php b/examples/php/addressbook.proto.php
deleted file mode 100644
index 2b03d05..0000000
--- a/examples/php/addressbook.proto.php
+++ /dev/null
@@ -1,181 +0,0 @@
-<?php
-
-/**
- * Tutorial_Person_PhoneNumber
- *
- * @message Tutorial.Person.PhoneNumber
- *
- */
-class Tutorial_Person_PhoneNumber extends ProtocolBuffersMessage
-{
-  protected $number;
-
-  protected $type;
-
-
-  /**
-   * get descriptor for protocol buffers
-   * 
-   * @return array
-   */
-  public static function getDescriptor()
-  {
-    static $descriptor;
-
-    if (!isset($descriptor)) {
-      $desc = new ProtocolBuffersDescriptorBuilder();
-      $desc->addField(1, new ProtocolBuffersFieldDescriptor(array(
-        "type"     => ProtocolBuffers::TYPE_STRING,
-        "name"     => "number",
-        "required" => true,
-        "optional" => false,
-        "repeated" => false,
-        "packable" => false,
-        "default"  => "",
-      )));
-      $desc->addField(2, new ProtocolBuffersFieldDescriptor(array(
-        "type"     => ProtocolBuffers::TYPE_ENUM,
-        "name"     => "type",
-        "required" => false,
-        "optional" => true,
-        "repeated" => false,
-        "packable" => false,
-        "default"  => Tutorial_Person_PhoneType::HOME,
-      )));
-      $descriptor = $desc->build();
-    }
-
-    return $descriptor;
-  }
-
-}
-
-/**
- * Tutorial_Person_PhoneType
- *
- * @enum Tutorial.Person.PhoneType
- */
-class Tutorial_Person_PhoneType
-{
-  const MOBILE = 0;
-  const HOME = 1;
-  const WORK = 2;
-}
-
-/**
- * Tutorial_Person
- *
- * @message Tutorial.Person
- *
- */
-class Tutorial_Person extends ProtocolBuffersMessage
-{
-  protected $name;
-
-  protected $id;
-
-  protected $email;
-
-  protected $phone = array();
-
-    public function addPhone($a)
-    {
-        $this->phone[] = $a;
-    }
-
-  /**
-   * get descriptor for protocol buffers
-   * 
-   * @return array
-   */
-  public static function getDescriptor()
-  {
-    static $descriptor;
-
-    if (!isset($descriptor)) {
-      $desc = new ProtocolBuffersDescriptorBuilder();
-      $desc->addField(1, new ProtocolBuffersFieldDescriptor(array(
-        "type"     => ProtocolBuffers::TYPE_STRING,
-        "name"     => "name",
-        "required" => true,
-        "optional" => false,
-        "repeated" => false,
-        "packable" => false,
-        "default"  => "",
-      )));
-      $desc->addField(2, new ProtocolBuffersFieldDescriptor(array(
-        "type"     => ProtocolBuffers::TYPE_INT32,
-        "name"     => "id",
-        "required" => true,
-        "optional" => false,
-        "repeated" => false,
-        "packable" => false,
-        "default"  => 0,
-      )));
-      $desc->addField(3, new ProtocolBuffersFieldDescriptor(array(
-        "type"     => ProtocolBuffers::TYPE_STRING,
-        "name"     => "email",
-        "required" => false,
-        "optional" => true,
-        "repeated" => false,
-        "packable" => false,
-        "default"  => "",
-      )));
-      $desc->addField(4, new ProtocolBuffersFieldDescriptor(array(
-        "type"     => ProtocolBuffers::TYPE_MESSAGE,
-        "name"     => "phone",
-        "required" => false,
-        "optional" => false,
-        "repeated" => true,
-        "packable" => false,
-        "default"  => null,
-        "message"  => "Tutorial_Person_PhoneNumber",
-      )));
-      $descriptor = $desc->build();
-    }
-
-    return $descriptor;
-  }
-
-}
-
-/**
- * Tutorial_AddressBook
- *
- * @message Tutorial.AddressBook
- *
- */
-class Tutorial_AddressBook extends ProtocolBuffersMessage
-{
-  protected $person = array();
-
-
-  /**
-   * get descriptor for protocol buffers
-   * 
-   * @return array
-   */
-  public static function getDescriptor()
-  {
-    static $descriptor;
-
-    if (!isset($descriptor)) {
-      $desc = new ProtocolBuffersDescriptorBuilder();
-      $desc->addField(1, new ProtocolBuffersFieldDescriptor(array(
-        "type"     => ProtocolBuffers::TYPE_MESSAGE,
-        "name"     => "person",
-        "required" => false,
-        "optional" => false,
-        "repeated" => true,
-        "packable" => false,
-        "default"  => null,
-        "message"  => "Tutorial_Person",
-      )));
-      $descriptor = $desc->build();
-    }
-
-    return $descriptor;
-  }
-
-}
-
diff --git a/examples/php/prefecture.proto.php b/examples/php/prefecture.proto.php
deleted file mode 100644
index 3575e73..0000000
--- a/examples/php/prefecture.proto.php
+++ /dev/null
@@ -1,137 +0,0 @@
-<?php
-/**
- * Tutorial_Prefecture
- *
- * @message Tutorial.Prefecture
- *
- */
-class Tutorial_Prefecture extends ProtocolBuffersMessage
-{
-  protected $id;
-
-  protected $name;
-
-  protected $population;
-
-  protected $area;
-
-  protected $population_density;
-
-
-  /**
-   * get descriptor for protocol buffers
-   * 
-   * @return array
-   */
-  public static function getDescriptor()
-  {
-    static $descriptor;
-
-    if (!isset($descriptor)) {
-      $desc = new ProtocolBuffersDescriptorBuilder();
-      $desc->addField(1, new ProtocolBuffersFieldDescriptor(array(
-        "type"     => ProtocolBuffers::TYPE_UINT32,
-        "name"     => "id",
-        "required" => true,
-        "optional" => false,
-        "repeated" => false,
-        "packable" => false,
-        "default"  => 0,
-      )));
-      $desc->addField(2, new ProtocolBuffersFieldDescriptor(array(
-        "type"     => ProtocolBuffers::TYPE_STRING,
-        "name"     => "name",
-        "required" => false,
-        "optional" => true,
-        "repeated" => false,
-        "packable" => false,
-        "default"  => "",
-      )));
-      $desc->addField(3, new ProtocolBuffersFieldDescriptor(array(
-        "type"     => ProtocolBuffers::TYPE_UINT32,
-        "name"     => "population",
-        "required" => false,
-        "optional" => true,
-        "repeated" => false,
-        "packable" => false,
-        "default"  => 0,
-      )));
-      $desc->addField(4, new ProtocolBuffersFieldDescriptor(array(
-        "type"     => ProtocolBuffers::TYPE_UINT32,
-        "name"     => "area",
-        "required" => false,
-        "optional" => true,
-        "repeated" => false,
-        "packable" => false,
-        "default"  => 0,
-      )));
-      $desc->addField(5, new ProtocolBuffersFieldDescriptor(array(
-        "type"     => ProtocolBuffers::TYPE_UINT32,
-        "name"     => "population_density",
-        "required" => false,
-        "optional" => true,
-        "repeated" => false,
-        "packable" => false,
-        "default"  => 0,
-      )));
-      $descriptor = $desc->build();
-    }
-
-    return $descriptor;
-  }
-
-}
-
-/**
- * Tutorial_Japan
- *
- * @message Tutorial.Japan
- *
- */
-class Tutorial_Japan extends ProtocolBuffersMessage
-{
-  protected $prefecture = array();
-
-    public function __destruct()
-    {
-        $this->prefecture = array();
-    }
-
-    public function addPrefecture($p)
-    {
-        $this->prefecture[] = $p;
-    }
-    public function debugPrefecture()
-    {
-        ProtocolBuffersHelper::debugZval($this->prefecture);
-    }
-
-  /**
-   * get descriptor for protocol buffers
-   * 
-   * @return array
-   */
-  public static function getDescriptor()
-  {
-    static $descriptor;
-
-    if (!isset($descriptor)) {
-      $desc = new ProtocolBuffersDescriptorBuilder();
-      $desc->addField(1, new ProtocolBuffersFieldDescriptor(array(
-        "type"     => ProtocolBuffers::TYPE_MESSAGE,
-        "name"     => "prefecture",
-        "required" => false,
-        "optional" => false,
-        "repeated" => true,
-        "packable" => false,
-        "default"  => null,
-        "message"  => "Tutorial_Prefecture",
-      )));
-      $descriptor = $desc->build();
-    }
-
-    return $descriptor;
-  }
-
-}
-
diff --git a/examples/prefecture.php b/examples/prefecture.php
deleted file mode 100644
index 4b5a17a..0000000
--- a/examples/prefecture.php
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-require dirname(__FILE__) . DIRECTORY_SEPARATOR . join(DIRECTORY_SEPARATOR, array("php", "prefecture.proto.php"));
-
-$a = file_get_contents("prefecture.tsv");
-
-$jpn = new Tutorial_Japan();
-$i = 1;
-foreach (explode("\n", $a) as $line) {
-    $line = trim($line);
-    if (empty($line)) {
-        continue;
-    }
-
-    $args = explode("\t", trim($line));
-    $prefecture = new Tutorial_Prefecture();
-    $prefecture->setId($i);
-    $prefecture->setName($args[0]);
-    $prefecture->setPopulation($args[1]);
-    $prefecture->setArea($args[2]);
-    $prefecture->setPopulationDensity($args[3]);
-
-    $jpn->appendPrefecture($prefecture);
-    $i++;
-}
-
-file_put_contents("prefecture.db", $jpn->serializeToString());
-
-$data = $jpn->serializeToString();
-$data = file_get_contents("prefecture.db");
-
-printf("# decoding benchmark (protocolbuffers).\n");
-printf("# target message size: %d bytes.\n", strlen($data));
-printf("# start\n");
-
-$begin = microtime(true);
-$attempts = 10000;
-for ($i = 0; $i < $attempts; $i++) {
-    ProtocolBuffers::decode("Tutorial_Japan", $data);
-}
-$end = microtime(true);
-
-printf("# Result:\n");
-printf("# decoding %d messages\n", $attempts);
-printf("# processing time: %6f (%f/message)\n", $end - $begin, ($end - $begin) / $attempts);
-printf("# total bytes: %d bytes\n", strlen($data) * $attempts);
diff --git a/examples/prefecture.proto b/examples/prefecture.proto
deleted file mode 100644
index 216eb0e..0000000
--- a/examples/prefecture.proto
+++ /dev/null
@@ -1,13 +0,0 @@
-package Tutorial;
-
-message Prefecture {
-	required uint32 id = 1;
-	optional string name = 2;
-	optional uint32 population = 3;
-	optional uint32 area = 4;
-	optional uint32 population_density = 5;
-}
-
-message Japan {
-	repeated Prefecture prefecture = 1;
-}
diff --git a/examples/prefecture.tsv b/examples/prefecture.tsv
deleted file mode 100644
index 9cf0f14..0000000
--- a/examples/prefecture.tsv
+++ /dev/null
@@ -1,47 +0,0 @@
-東京都	13216221	6038	2189
-北海道	78421	5460668	70
-神奈川県	9072133	3755	2416
-岩手県	15279	1303351	85
-大阪府	4661	8863324	1901
-福島県	13783	1962333	142
-愛知県	7425952	1438	5165
-長野県	13562	2133014	157
-埼玉県	1898	7208122	3798
-新潟県	12584	2347092	187
-千葉県	6195576	1201	5157
-秋田県	11636	1063168	91
-兵庫県	5571096	664	8396
-岐阜県	10621	2064940	194
-福岡県	1021	5085368	4979
-青森県	9645	1349899	140
-山形県	9323	1151863	124
-沖縄県	619	1410138	2277
-静岡県	3736600	7781	480
-鹿児島県	9189	1689397	184
-京都府	570	2627313	4613
-茨城県	2945824	483	6096
-広島県	8480	2849104	336
-香川県	527	989159	1877
-宮崎県	7736	1126132	146
-奈良県	377	1389690	3691
-宮城県	2325407	7286	319
-熊本県	7405	1807201	244
-滋賀県	353	1416546	4017
-佐賀県	346	843505	2440
-岡山県	7113	1936575	272
-長崎県	343	1407904	4106
-栃木県	1993386	6408	311
-高知県	7105	106	752042
-群馬県	1992432	6362	313
-島根県	6708	105	707074
-三重県	318	1838611	5777
-大分県	6340	1185830	187
-山口県	6114	1431294	234
-石川県	278	1162953	4186
-富山県	255	4248	1082763
-愛媛県	5679	249	1414996
-和歌山県	209	4726	987483
-福井県	191	4190	799127
-山梨県	4465	191	851681
-徳島県	187	4147	775871
-鳥取県	166	3507	581870
diff --git a/examples/uv/README.md b/examples/uv/README.md
deleted file mode 100644
index f60b010..0000000
--- a/examples/uv/README.md
+++ /dev/null
@@ -1,46 +0,0 @@
-# Protocol Buffer Example
-
-Overview
---------
-
-this example explains memcached like server which using protocol buffers.
-
-Requirements
-------------
-
-* php 5.3 higher
-* php-uv (https://github.com/chobie/php-uv/)
-
-
-Generate messages
------------------
-
-````
-protoc --plugin=../../contrib/protoc-gen-php message.proto --php_out=proto -I . -I /usr/local/include
-````
-
-Starting Server Process
------------------------
-
-```
-php server.php
-````
-
-you need to run server process when playing this example.
-
-
-SET operation
--------------
-
-````
-// php client.php SET <KEY> <VALUE>
-php client.php SET chobie "Helo World"
-````
-
-GET operation
--------------
-
-````
-// php client.php GET <KEY>
-php client.php GET chobie
-````
diff --git a/examples/uv/client.php b/examples/uv/client.php
deleted file mode 100644
index 0e1c975..0000000
--- a/examples/uv/client.php
+++ /dev/null
@@ -1,60 +0,0 @@
-<?php
-require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "proto" . DIRECTORY_SEPARATOR . "message.proto.php";
-
-$type = $_SERVER['argv'][1];
-$key = $_SERVER['argv'][2];
-
-if ($type == "SET") {
-    $value = $_SERVER['argv'][3];
-}
-
-
-function getRequestType($type)
-{
-    $key = strtolower($type);
-    switch ($key) {
-    case "set":
-        return ProtocolCached_Request_RequestType::SET;
-        break;
-    case "get":
-        return ProtocolCached_Request_RequestType::GET;
-        break;
-    default:
-        throw new Exception("GET or SET only");
-    }
-}
-
-$c = uv_tcp_init();
-uv_tcp_connect6($c, uv_ip6_addr('::1', 9999), function($client, $stat){
-    if ($stat == 0) {
-        $request = new ProtocolCached_Request();
-        $type = getRequestType($_SERVER['argv'][1]);
-        $request->setType($type);
-
-        if ($type == ProtocolCached_Request_RequestType::SET) {
-            $set = new ProtocolCached_SetRequest();
-            $set->setKey($_SERVER['argv'][2]);
-            $set->setValue($_SERVER['argv'][3]);
-
-            $request->setSet($set);
-        } else if ($type == ProtocolCached_Request_RequestType::GET) {
-            $set = new ProtocolCached_GetRequest();
-            $set->setKey($_SERVER['argv'][2]);
-
-            $request->setGet($set);
-        }
-
-        uv_write($client, $request->serializeToString(),function($socket, $stat) use($type){
-            if ($type == ProtocolCached_Request_RequestType::GET) {
-                uv_read_start($socket, function($socket, $nread, $buffer) use ($type){
-                    var_dump(ProtocolCached_Response::parseFromString($buffer));
-                    uv_close($socket);
-                });
-            } else {
-                uv_close($socket);
-            }
-        });
-    }
-});
-
-uv_run();
\ No newline at end of file
diff --git a/examples/uv/message.proto b/examples/uv/message.proto
deleted file mode 100644
index 9a2dce9..0000000
--- a/examples/uv/message.proto
+++ /dev/null
@@ -1,36 +0,0 @@
-package ProtocolCached;
-
-message Request {
-	enum RequestType
-	{
-		GET = 1;
-		SET = 2;
-	}
-	required RequestType type = 1 [default = GET];
-	optional SetRequest set = 2;
-	optional GetRequest get = 3;
-}
-
-message Response {
-	enum ResponseType
-	{
-		GET = 1;
-		SET = 2;
-	}
-	required ResponseType type = 1 [default = GET];
-	optional GetResponse get = 2;
-}
-
-message SetRequest {
-	required bytes key = 1;
-	required bytes value = 2;
-}
-
-message GetRequest {
-	required bytes key = 1;
-}
-
-
-message GetResponse {
-	required bytes value = 1;
-}
\ No newline at end of file
diff --git a/examples/uv/proto/message.proto.php b/examples/uv/proto/message.proto.php
deleted file mode 100644
index 44b1eb9..0000000
--- a/examples/uv/proto/message.proto.php
+++ /dev/null
@@ -1,265 +0,0 @@
-<?php
-/**
- * ProtocolCached_Request_RequestType
- *
- * @enum ProtocolCached.Request.RequestType
- */
-class ProtocolCached_Request_RequestType
-{
-  const GET = 1;
-  const SET = 2;
-}
-
-/**
- * ProtocolCached_Request
- *
- * @message ProtocolCached.Request
- *
- */
-class ProtocolCached_Request extends ProtocolBuffersMessage
-{
-  protected $type;
-
-  protected $set;
-
-  protected $get;
-
-
-  /**
-   * get descriptor for protocol buffers
-   * 
-   * @return array
-   */
-  public static function getDescriptor()
-  {
-    static $descriptor;
-
-    if (!isset($descriptor)) {
-      $desc = new ProtocolBuffersDescriptorBuilder();
-      $desc->addField(1, new ProtocolBuffersFieldDescriptor(array(
-        "type"     => ProtocolBuffers::TYPE_ENUM,
-        "name"     => "type",
-        "required" => true,
-        "optional" => false,
-        "repeated" => false,
-        "packable" => false,
-        "default"  => ProtocolCached_Request_RequestType::GET,
-      )));
-      $desc->addField(2, new ProtocolBuffersFieldDescriptor(array(
-        "type"     => ProtocolBuffers::TYPE_MESSAGE,
-        "name"     => "set",
-        "required" => false,
-        "optional" => true,
-        "repeated" => false,
-        "packable" => false,
-        "default"  => null,
-        "message"  => "ProtocolCached_SetRequest",
-      )));
-      $desc->addField(3, new ProtocolBuffersFieldDescriptor(array(
-        "type"     => ProtocolBuffers::TYPE_MESSAGE,
-        "name"     => "get",
-        "required" => false,
-        "optional" => true,
-        "repeated" => false,
-        "packable" => false,
-        "default"  => null,
-        "message"  => "ProtocolCached_GetRequest",
-      )));
-      $descriptor = $desc->build();
-    }
-
-    return $descriptor;
-  }
-
-}
-
-/**
- * ProtocolCached_Response_ResponseType
- *
- * @enum ProtocolCached.Response.ResponseType
- */
-class ProtocolCached_Response_ResponseType
-{
-  const GET = 1;
-  const SET = 2;
-}
-
-/**
- * ProtocolCached_Response
- *
- * @message ProtocolCached.Response
- *
- */
-class ProtocolCached_Response extends ProtocolBuffersMessage
-{
-  protected $type;
-
-  protected $get;
-
-
-  /**
-   * get descriptor for protocol buffers
-   * 
-   * @return array
-   */
-  public static function getDescriptor()
-  {
-    static $descriptor;
-
-    if (!isset($descriptor)) {
-      $desc = new ProtocolBuffersDescriptorBuilder();
-      $desc->addField(1, new ProtocolBuffersFieldDescriptor(array(
-        "type"     => ProtocolBuffers::TYPE_ENUM,
-        "name"     => "type",
-        "required" => true,
-        "optional" => false,
-        "repeated" => false,
-        "packable" => false,
-        "default"  => ProtocolCached_Response_ResponseType::GET,
-      )));
-      $desc->addField(2, new ProtocolBuffersFieldDescriptor(array(
-        "type"     => ProtocolBuffers::TYPE_MESSAGE,
-        "name"     => "get",
-        "required" => false,
-        "optional" => true,
-        "repeated" => false,
-        "packable" => false,
-        "default"  => null,
-        "message"  => "ProtocolCached_GetResponse",
-      )));
-      $descriptor = $desc->build();
-    }
-
-    return $descriptor;
-  }
-
-}
-
-/**
- * ProtocolCached_SetRequest
- *
- * @message ProtocolCached.SetRequest
- *
- */
-class ProtocolCached_SetRequest extends ProtocolBuffersMessage
-{
-  protected $key;
-
-  protected $value;
-
-
-  /**
-   * get descriptor for protocol buffers
-   * 
-   * @return array
-   */
-  public static function getDescriptor()
-  {
-    static $descriptor;
-
-    if (!isset($descriptor)) {
-      $desc = new ProtocolBuffersDescriptorBuilder();
-      $desc->addField(1, new ProtocolBuffersFieldDescriptor(array(
-        "type"     => ProtocolBuffers::TYPE_BYTES,
-        "name"     => "key",
-        "required" => true,
-        "optional" => false,
-        "repeated" => false,
-        "packable" => false,
-        "default"  => "",
-      )));
-      $desc->addField(2, new ProtocolBuffersFieldDescriptor(array(
-        "type"     => ProtocolBuffers::TYPE_BYTES,
-        "name"     => "value",
-        "required" => true,
-        "optional" => false,
-        "repeated" => false,
-        "packable" => false,
-        "default"  => "",
-      )));
-      $descriptor = $desc->build();
-    }
-
-    return $descriptor;
-  }
-
-}
-
-/**
- * ProtocolCached_GetRequest
- *
- * @message ProtocolCached.GetRequest
- *
- */
-class ProtocolCached_GetRequest extends ProtocolBuffersMessage
-{
-  protected $key;
-
-
-  /**
-   * get descriptor for protocol buffers
-   * 
-   * @return array
-   */
-  public static function getDescriptor()
-  {
-    static $descriptor;
-
-    if (!isset($descriptor)) {
-      $desc = new ProtocolBuffersDescriptorBuilder();
-      $desc->addField(1, new ProtocolBuffersFieldDescriptor(array(
-        "type"     => ProtocolBuffers::TYPE_BYTES,
-        "name"     => "key",
-        "required" => true,
-        "optional" => false,
-        "repeated" => false,
-        "packable" => false,
-        "default"  => "",
-      )));
-      $descriptor = $desc->build();
-    }
-
-    return $descriptor;
-  }
-
-}
-
-/**
- * ProtocolCached_GetResponse
- *
- * @message ProtocolCached.GetResponse
- *
- */
-class ProtocolCached_GetResponse extends ProtocolBuffersMessage
-{
-  protected $value;
-
-
-  /**
-   * get descriptor for protocol buffers
-   * 
-   * @return array
-   */
-  public static function getDescriptor()
-  {
-    static $descriptor;
-
-    if (!isset($descriptor)) {
-      $desc = new ProtocolBuffersDescriptorBuilder();
-      $desc->addField(1, new ProtocolBuffersFieldDescriptor(array(
-        "type"     => ProtocolBuffers::TYPE_BYTES,
-        "name"     => "value",
-        "required" => true,
-        "optional" => false,
-        "repeated" => false,
-        "packable" => false,
-        "default"  => "",
-      )));
-      $descriptor = $desc->build();
-    }
-
-    return $descriptor;
-  }
-
-}
-
diff --git a/examples/uv/server.php b/examples/uv/server.php
deleted file mode 100644
index bcb9383..0000000
--- a/examples/uv/server.php
+++ /dev/null
@@ -1,94 +0,0 @@
-<?php
-require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "proto" . DIRECTORY_SEPARATOR . "message.proto.php";
-
-class KeyValueStore
-{
-    protected $store = array();
-
-    public function __construct()
-    {
-    }
-
-    public function count()
-    {
-        return count($this->store);
-    }
-
-    public function set($key, $value)
-    {
-        $this->store[$key] = $value;
-    }
-
-    public function get($key)
-    {
-        $result = NULL;
-
-        if (isset($this->store[$key])) {
-            $result = $this->store[$key];
-        }
-        return $result;
-    }
-}
-
-$store = new KeyValueStore();
-
-$tcp = uv_tcp_init();
-uv_tcp_bind6($tcp, uv_ip6_addr('::1',9999));
-echo "# Server listening to ::1 9999\n";
-
-uv_listen($tcp, 100, function($server) use ($store){
-    $client = uv_tcp_init();
-    uv_accept($server, $client);
-    echo "# Accepted\n";
-
-    uv_read_start($client, function($socket, $nread, $buffer) use ($server, $store){
-        try {
-            $result = null;
-            $request = ProtocolCached_Request::parseFromString($buffer);
-
-            switch ($request->getType()) {
-            case ProtocolCached_Request_RequestType::SET:
-                echo sprintf("# set operation: %d, %d\n", $request->getSet()->getKey(), strlen($request->getSet()->getValue()));
-                $store->set($request->getSet()->getKey(), $request->getSet()->getValue());
-                var_dump($store);
-                var_dump($request);
-                break;
-            case ProtocolCached_Request_RequestType::GET:
-                $result = $store->get($request->getGet()->getKey());
-                break;
-            }
-
-        } catch (ProtocolBuffers\InvalidProtocoBufferException $e) {
-            echo $e->getMessage();
-        }
-
-        if ($result) {
-            $response = new ProtocolCached_Response();
-            $response->setType(ProtocolCached_Response_ResponseType::GET);
-            $payload = new ProtocolCached_GetResponse();
-            $payload->setValue($result);
-            $response->setGet($payload);
-
-            uv_write($socket, $response->serializeToString(), function($socket, $stat) {
-                echo "# Connection closed\n";
-                uv_close($socket);
-            });
-        } else {
-            echo "# Connection closed\n";
-            uv_close($socket);
-        }
-    });
-});
-
-$timer = uv_timer_init();
-
-$stat = array();
-$stat['begin'] = memory_get_usage();
-
-uv_timer_start($timer, 10, 1000, function($stat, $timer) use (&$stat, $store){
-    $stat["current"] = memory_get_usage();
-    printf("# memory: %d\n", $stat["current"] - $stat['begin']);
-    printf("# collection size: %d\n", $store->count());
-});
-
-uv_run();
\ No newline at end of file
diff --git a/package.xml b/package.xml
deleted file mode 100644
index 4acb214..0000000
--- a/package.xml
+++ /dev/null
@@ -1,365 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<package version="2.1" xmlns="http://pear.php.net/dtd/package-2.1" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0     http://pear.php.net/dtd/tasks-1.0.xsd     http://pear.php.net/dtd/package-2.1     http://pear.php.net/dtd/package-2.1.xsd">
- <name>protocolbuffers</name>
- <channel>pecl.php.net</channel>
- <summary>Protocol Buffers are a way of encoding structured data in an efficient yet extensible format. Google uses Protocol Buffers for almost all of its internal RPC protocols and file formats.
-</summary>
- <description>Protocol buffers are a flexible, efficient, automated mechanism for serializing structured data think XML, but smaller, faster, and simpler. You define how you want your data to be structured once, then you can use special generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages. You can even update your data structure without breaking deployed programs that are compiled against the "old" format.</description>
- <lead>
-  <name>Shuhei Tanuma</name>
-  <user>chobieeee</user>
-  <email>chobieeeee@php.net</email>
-  <active>yes</active>
- </lead>
- <date>2014-04-15</date>
- <time>12:55:30</time>
- <version>
-  <release>0.2.6</release>
-  <api>0.2.3</api>
- </version>
- <stability>
-  <release>alpha</release>
-  <api>alpha</api>
- </stability>
- <license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license>
- <notes>Bumped up to 0.2.6
-* fixed several compile warnings (thanks remi)
-
-[fixes]
-* (ExtensionRegistry) initialize class entry member when reallocating scheme.
-
- </notes>
- <contents>
- <dir name="/">
-     <file role="src" name="config.m4"/>
-     <file role="src" name="config.w32"/>
-     <file role="src" name="core.c"/>
-     <file role="src" name="core.h"/>
-     <file role="src" name="core_inl.h"/>
-     <file role="doc" name="CREDITS"/>
-     <file role="src" name="descriptor.c"/>
-     <file role="src" name="descriptor.h"/>
-     <file role="src" name="descriptor_builder.c"/>
-     <file role="src" name="descriptor_builder.h"/>
-     <file role="src" name="enum.c"/>
-     <file role="src" name="enum.h"/>
-     <file role="src" name="enum_descriptor.c"/>
-     <file role="src" name="enum_descriptor.h"/>
-     <file role="src" name="enum_descriptor_builder.c"/>
-     <file role="src" name="enum_descriptor_builder.h"/>
-     <file role="src" name="enum_value_descriptor.c"/>
-     <file role="src" name="enum_value_descriptor.h"/>
-     <file role="doc" name="EXPERIMENTAL"/>
-     <file role="src" name="extension_registry.c"/>
-     <file role="src" name="extension_registry.h"/>
-     <file role="src" name="field_descriptor.c"/>
-     <file role="src" name="field_descriptor.h"/>
-     <file role="src" name="helper.c"/>
-     <file role="src" name="helper.h"/>
-     <file role="doc" name="LICENSE"/>
-     <file role="src" name="message.c"/>
-     <file role="src" name="message.h"/>
-     <file role="src" name="message_options.c"/>
-     <file role="src" name="message_options.h"/>
-     <file role="src" name="php_message_options.c"/>
-     <file role="src" name="php_message_options.h"/>
-     <file role="src" name="php_protocolbuffers.h"/>
-     <file role="src" name="phpunit.xml.dist"/>
-     <file role="src" name="protocolbuffers.c"/>
-     <file role="src" name="protocolbuffers.h"/>
-     <file role="doc" name="README.md"/>
-     <file role="src" name="serializer.c"/>
-     <file role="src" name="serializer.h"/>
-     <file role="src" name="json_serializer.c"/>
-     <file role="src" name="json_serializer.h"/>
-     <file role="src" name="unknown_field.c"/>
-     <file role="src" name="unknown_field.h"/>
-     <file role="src" name="unknown_field_set.c"/>
-     <file role="src" name="unknown_field_set.h"/>
-     <dir name="stubs">
-         <file role="doc" name="protocolbuffers.stub.php"/>
-     </dir>
-     <dir name="tests">
-         <file role="test" name="000_aliases.phpt"/>
-         <file role="test" name="001_big_tag.phpt"/>
-         <file role="test" name="001_bool.phpt"/>
-         <file role="test" name="001_bytes.phpt"/>
-         <file role="test" name="001_constants.phpt"/>
-         <file role="test" name="001_double_sample.phpt"/>
-         <file role="test" name="001_fixed32_init.phpt"/>
-         <file role="test" name="001_fixed32_max.phpt"/>
-         <file role="test" name="001_fixed64_init.phpt"/>
-         <file role="test" name="001_fixed64_max.phpt"/>
-         <file role="test" name="001_float_sample.phpt"/>
-         <file role="test" name="001_float_signed.phpt"/>
-         <file role="test" name="001_int32_init.phpt"/>
-         <file role="test" name="001_int32_max.phpt"/>
-         <file role="test" name="001_int32_min.phpt"/>
-         <file role="test" name="001_int64_init.phpt"/>
-         <file role="test" name="001_int64_max.phpt"/>
-         <file role="test" name="001_int64_min.phpt"/>
-         <file role="test" name="001_sfixed32_signed.phpt"/>
-         <file role="test" name="001_sfixed32_unsigned.phpt"/>
-         <file role="test" name="001_sfixed64_init.phpt"/>
-         <file role="test" name="001_sfixed64_max.phpt"/>
-         <file role="test" name="001_sfixed64_min.phpt"/>
-         <file role="test" name="001_sint32_init.phpt"/>
-         <file role="test" name="001_sint32_max.phpt"/>
-         <file role="test" name="001_sint32_min.phpt"/>
-         <file role="test" name="001_sint64.init.phpt"/>
-         <file role="test" name="001_sint64_max.phpt"/>
-         <file role="test" name="001_sint64_min.phpt"/>
-         <file role="test" name="001_string_0bytes.phpt"/>
-         <file role="test" name="001_string_1024bytes.phpt"/>
-         <file role="test" name="001_string_invaild_encoding.phpt"/>
-         <file role="test" name="001_string_invalid_encoding_with_no_string_validate.phpt"/>
-         <file role="test" name="001_string_should_keep_object.phpt"/>
-         <file role="test" name="001_string_small.phpt"/>
-         <file role="test" name="001_string_utf8.phpt"/>
-         <file role="test" name="001_uint64_max.phpt"/>
-         <file role="test" name="002_repeated_int32.phpt"/>
-         <file role="test" name="002_repeated_message.phpt"/>
-         <file role="test" name="002_repeated_string.phpt"/>
-         <file role="test" name="002_simple_encode.phpt"/>
-         <file role="test" name="003_bool_packed.phpt"/>
-         <file role="test" name="003_double_packed.phpt"/>
-         <file role="test" name="003_fixed32_packed.phpt"/>
-         <file role="test" name="003_fixed64_packed.phpt"/>
-         <file role="test" name="003_float_packed.phpt"/>
-         <file role="test" name="003_has_message_decode.phpt"/>
-         <file role="test" name="003_has_message_encode.phpt"/>
-         <file role="test" name="003_int32_packed.phpt"/>
-         <file role="test" name="003_int32_packed_many.phpt"/>
-         <file role="test" name="003_int64_packed.phpt"/>
-         <file role="test" name="003_sfixed32_packed.phpt"/>
-         <file role="test" name="003_sfixed64_packed.phpt"/>
-         <file role="test" name="003_sint32_packed.phpt"/>
-         <file role="test" name="003_sint64_packed.phpt"/>
-         <file role="test" name="003_uint32_packed.phpt"/>
-         <file role="test" name="004_decode_bool.phpt"/>
-         <file role="test" name="004_decode_bytes.phpt"/>
-         <file role="test" name="004_decode_double_sample.phpt"/>
-         <file role="test" name="004_decode_fixed32_init.phpt"/>
-         <file role="test" name="004_decode_fixed32_max.phpt"/>
-         <file role="test" name="004_decode_float_sample.phpt"/>
-         <file role="test" name="004_decode_float_signed.phpt"/>
-         <file role="test" name="004_decode_int32_init.phpt"/>
-         <file role="test" name="004_decode_int32_max.phpt"/>
-         <file role="test" name="004_decode_int32_min.phpt"/>
-         <file role="test" name="004_decode_sfixed32_signed.phpt"/>
-         <file role="test" name="004_decode_sfixed32_unsigned.phpt"/>
-         <file role="test" name="004_decode_sint32_init.phpt"/>
-         <file role="test" name="004_decode_sint32_max.phpt"/>
-         <file role="test" name="004_decode_sint32_min.phpt"/>
-         <file role="test" name="004_decode_string_0bytes.phpt"/>
-         <file role="test" name="004_decode_string_1024bytes.phpt"/>
-         <file role="test" name="005_decode_bool_packed.phpt"/>
-         <file role="test" name="005_decode_double_packed.phpt"/>
-         <file role="test" name="005_decode_fixed32_packed.phpt"/>
-         <file role="test" name="005_decode_fixed64_packed.phpt"/>
-         <file role="test" name="005_decode_float_packed.phpt"/>
-         <file role="test" name="005_decode_int32_packed.phpt"/>
-         <file role="test" name="005_decode_int32_packed_many.phpt"/>
-         <file role="test" name="005_decode_int64_packed.phpt"/>
-         <file role="test" name="005_decode_sfixed32_packed.phpt"/>
-         <file role="test" name="005_decode_sfixed64_packed.phpt"/>
-         <file role="test" name="005_decode_sint32_packed.phpt"/>
-         <file role="test" name="005_decode_sint64_packed.phpt"/>
-         <file role="test" name="100_field_descriptor.phpt"/>
-         <file role="test" name="101_descirptor_builder.phpt"/>
-         <file role="test" name="102_descriptor_builder_with_noargs.phpt"/>
-         <file role="test" name="103_descriptor_force_add.phpt"/>
-         <file role="test" name="103_descriptor_throws_an_exception.phpt"/>
-         <file role="test" name="104_descriptor_builder_add_extension_range.phpt"/>
-         <file role="test" name="105_enum_descriptor_builder.phpt"/>
-         <file role="test" name="200_unknown_fields.phpt"/>
-         <file role="test" name="200_unknown_fields_discard.phpt"/>
-         <file role="test" name="300_use_single_property.phpt"/>
-         <file role="test" name="400_message_clear.phpt"/>
-         <file role="test" name="400_message_clear_all.phpt"/>
-         <file role="test" name="400_message_iterator.phpt"/>
-         <file role="test" name="400_message_magicmethods.phpt"/>
-         <file role="test" name="500_unknown_bytes.phpt"/>
-         <file role="test" name="500_unknown_double.phpt"/>
-         <file role="test" name="500_unknown_float.phpt"/>
-         <file role="test" name="500_unknown_int32.phpt"/>
-         <file role="test" name="500_unknown_iterator.phpt"/>
-         <file role="test" name="500_unknown_repeated_string.phpt"/>
-         <file role="test" name="500_unknown_string.phpt"/>
-         <file role="test" name="600_constructor.phpt"/>
-         <file role="test" name="600_extension.phpt"/>
-         <file role="test" name="600_extension_clear.phpt"/>
-         <file role="test" name="600_sleep.phpt"/>
-         <file role="test" name="600_wakeup.phpt"/>
-         <file role="test" name="700_merge_from.phpt"/>
-         <file role="test" name="700_set_from.phpt"/>
-         <file role="test" name="700_merge_from.phpt"/>
-         <file role="test" name="700_jsonserializable.phpt"/>
-         <file role="test" name="700_jsonserializable_invalid_utf8.phpt"/>
-         <file role="test" name="700_toarray_invalid_utf8.phpt"/>
-         <file role="test" name="800_helper_debug_zval.phpt"/>
-         <file role="test" name="800_helper_write_varint32.phpt"/>
-         <file role="test" name="800_helper_zigzag.phpt"/>
-         <file role="test" name="999_append.phpt"/>
-         <file role="test" name="999_bytes_bug.phpt"/>
-         <file role="test" name="999_conformance_quick.phpt"/>
-         <file role="test" name="999_default_value.phpt"/>
-         <file role="test" name="999_dont_accept_null_value.phpt"/>
-         <file role="test" name="999_dummy_string.phpt"/>
-         <file role="test" name="999_empty_string.phpt"/>
-         <file role="test" name="999_illegal_bytes.phpt"/>
-         <file role="test" name="999_magicmethod_snakecase_to_lower_case.phpt"/>
-         <file role="test" name="999_magicmethod_throw_exception_when_doesnt_resolve.phpt"/>
-         <file role="test" name="999_missing_message.phpt"/>
-         <file role="test" name="999_no15_varint_should_read_64bit_integer.phpt"/>
-         <file role="test" name="999_no25_setter_getter_consider_camel_case_fields.phpt"/>
-         <file role="test" name="999_no_19_regression_script_contains_large_number_literals.phpt"/>
-         <file role="test" name="999_no_8_magic_method_for_case_sensitive_field.phpt"/>
-         <file role="test" name="999_no_descriptor.phpt"/>
-         <file role="test" name="999_null.phpt"/>
-         <file role="test" name="999_number_larger_2_63-1.phpt"/>
-         <file role="test" name="999_php_message_options_set_single_property_name.phpt"/>
-         <file role="test" name="999_regression_multiple_repeated_fields.phpt"/>
-         <file role="test" name="999_remove_first_ns.phpt"/>
-         <file role="test" name="999_required_property.phpt"/>
-         <file role="test" name="999_no31_initialize_target_should_be_same_name_as_declarations.phpt" />
-         <file role="test" name="999_no33_batch_assignment.phpt" />
-         <dir name="fixtures">
-             <file role="test" name="001_big_tag.bin"/>
-             <file role="test" name="001_bool.bin"/>
-             <file role="test" name="001_bytes.bin"/>
-             <file role="test" name="001_double_sample.bin"/>
-             <file role="test" name="001_fixed32_init.bin"/>
-             <file role="test" name="001_fixed32_max.bin"/>
-             <file role="test" name="001_fixed64_init.bin"/>
-             <file role="test" name="001_fixed64_max.bin"/>
-             <file role="test" name="001_float_sample.bin"/>
-             <file role="test" name="001_float_signed.bin"/>
-             <file role="test" name="001_int32_init.bin"/>
-             <file role="test" name="001_int32_max.bin"/>
-             <file role="test" name="001_int32_min.bin"/>
-             <file role="test" name="001_int64_init.bin"/>
-             <file role="test" name="001_int64_max.bin"/>
-             <file role="test" name="001_int64_min.bin"/>
-             <file role="test" name="001_sfixed32_signed.bin"/>
-             <file role="test" name="001_sfixed32_unsigned.bin"/>
-             <file role="test" name="001_sfixed64_max.bin"/>
-             <file role="test" name="001_sfixed64_min.bin"/>
-             <file role="test" name="001_sfixed64_zero.bin"/>
-             <file role="test" name="001_sint32_init.bin"/>
-             <file role="test" name="001_sint32_max.bin"/>
-             <file role="test" name="001_sint32_min.bin"/>
-             <file role="test" name="001_sint64_init.bin"/>
-             <file role="test" name="001_sint64_max.bin"/>
-             <file role="test" name="001_sint64_min.bin"/>
-             <file role="test" name="001_string_0bytes.bin"/>
-             <file role="test" name="001_string_1024bytes.bin"/>
-             <file role="test" name="001_string_small.bin"/>
-             <file role="test" name="001_string_utf8.bin"/>
-             <file role="test" name="001_uint64_max.bin"/>
-             <file role="test" name="002_repeated_int32.bin"/>
-             <file role="test" name="002_repeated_message.bin"/>
-             <file role="test" name="002_repeated_string.bin"/>
-             <file role="test" name="002_simple_encode.bin"/>
-             <file role="test" name="003_bool_packed.bin"/>
-             <file role="test" name="003_double_packed.bin"/>
-             <file role="test" name="003_fixed32_packed.bin"/>
-             <file role="test" name="003_fixed64_packed.bin"/>
-             <file role="test" name="003_float_packed.bin"/>
-             <file role="test" name="003_has_message.bin"/>
-             <file role="test" name="003_int32_packed_many.bin"/>
-             <file role="test" name="003_int32_packed_one.bin"/>
-             <file role="test" name="003_int64_packed.bin"/>
-             <file role="test" name="003_sfixed32_packed.bin"/>
-             <file role="test" name="003_sfixed64_packed.bin"/>
-             <file role="test" name="003_sint32_packed.bin"/>
-             <file role="test" name="003_sint64_packed.bin"/>
-             <file role="test" name="003_uint32_packed.bin"/>
-             <file role="test" name="999_conformance_quick.bin"/>
-             <file role="test" name="android_logo.gif"/>
-             <file role="test" name="fixture001.bin"/>
-         </dir>
-         <dir name="messages">
-             <file role="test" name="003_has_message.proto.php"/>
-             <file role="test" name="addressbook.proto.php"/>
-             <file role="test" name="big_tag.proto.php"/>
-             <file role="test" name="field.proto.php"/>
-             <file role="test" name="field_bool.proto.php"/>
-             <file role="test" name="field_bool_packed.proto.php"/>
-             <file role="test" name="field_bytes.proto.php"/>
-             <file role="test" name="field_double.proto.php"/>
-             <file role="test" name="field_double_packed.proto.php"/>
-             <file role="test" name="field_fixed32.proto.php"/>
-             <file role="test" name="field_fixed32_packed.proto.php"/>
-             <file role="test" name="field_fixed64.proto.php"/>
-             <file role="test" name="field_fixed64_packed.proto.php"/>
-             <file role="test" name="field_float.proto.php"/>
-             <file role="test" name="field_float_packed.proto.php"/>
-             <file role="test" name="field_int32.proto.php"/>
-             <file role="test" name="field_int32_packed.proto.php"/>
-             <file role="test" name="field_int64.proto.php"/>
-             <file role="test" name="field_int64_packed.proto.php"/>
-             <file role="test" name="field_sfixed32.proto.php"/>
-             <file role="test" name="field_sfixed32_packed.proto.php"/>
-             <file role="test" name="field_sfixed64.proto.php"/>
-             <file role="test" name="field_sfixed64_packed.proto.php"/>
-             <file role="test" name="field_sint32.proto.php"/>
-             <file role="test" name="field_sint32_packed.proto.php"/>
-             <file role="test" name="field_sint64.proto.php"/>
-             <file role="test" name="field_sint64_packed.proto.php"/>
-             <file role="test" name="field_string.proto.php"/>
-             <file role="test" name="field_uint32_packed.proto.php"/>
-             <file role="test" name="field_uint64.proto.php"/>
-             <file role="test" name="repeated_int32.proto.php"/>
-             <file role="test" name="repeated_string.proto.php"/>
-             <file role="test" name="outer_inner.proto.php" />
-             <file role="test" name="AllTypes.proto.php" />
-         </dir>
-         <dir name="proto">
-             <file role="test" name="addressbook.proto"/>
-             <file role="test" name="big_tag.proto"/>
-             <file role="test" name="field_bool.proto"/>
-             <file role="test" name="field_bool_packed.proto"/>
-             <file role="test" name="field_bytes.proto"/>
-             <file role="test" name="field_double.proto"/>
-             <file role="test" name="field_double_packed.proto"/>
-             <file role="test" name="field_fixed32.proto"/>
-             <file role="test" name="field_fixed32_packed.proto"/>
-             <file role="test" name="field_fixed64.proto"/>
-             <file role="test" name="field_fixed64_packed.proto"/>
-             <file role="test" name="field_float.proto"/>
-             <file role="test" name="field_float_packed.proto"/>
-             <file role="test" name="field_int32.proto"/>
-             <file role="test" name="field_int32_packed.proto"/>
-             <file role="test" name="field_int64.proto"/>
-             <file role="test" name="field_int64_packed.proto"/>
-             <file role="test" name="field_sfixed32.proto"/>
-             <file role="test" name="field_sfixed32_packed.proto"/>
-             <file role="test" name="field_sfixed64.proto"/>
-             <file role="test" name="field_sfixed64_packed.proto"/>
-             <file role="test" name="field_sint32.proto"/>
-             <file role="test" name="field_sint32_packed.proto"/>
-             <file role="test" name="field_sint64.proto"/>
-             <file role="test" name="field_sint64_packed.proto"/>
-             <file role="test" name="field_string.proto"/>
-             <file role="test" name="field_uint32_packed.proto"/>
-             <file role="test" name="has_message.proto"/>
-             <file role="test" name="repeated_int32.proto"/>
-             <file role="test" name="repeated_string.proto"/>
-         </dir>
-     </dir>
- </dir>
- </contents>
- <dependencies>
-  <required>
-   <php>
-    <min>5.2.0</min>
-   </php>
-   <pearinstaller>
-    <min>1.4.8</min>
-   </pearinstaller>
-  </required>
- </dependencies>
- <providesextension>protocolbuffers</providesextension>
- <extsrcrelease/>
-</package>
diff --git a/tests/999_no41_constructor_should_accept_object.phpt b/tests/999_no41_constructor_should_accept_object.phpt
deleted file mode 100644
index b03129b..0000000
--- a/tests/999_no41_constructor_should_accept_object.phpt
+++ /dev/null
@@ -1,170 +0,0 @@
---TEST--
-#41 constructor should accept object
---FILE--
-<?php
-// @@protoc_insertion_point(namespace:.TestMessage)
-
-/**
- * Generated by the protocol buffer compiler.  DO NOT EDIT!
- * source: x.proto
- *
- * -*- magic methods -*-
- *
- * @method array getUsers()
- * @method void appendUsers(TestUser $value)
- */
-class TestMessage extends ProtocolBuffersMessage
-{
-  // @@protoc_insertion_point(traits:.TestMessage)
-  
-  /**
-   * @var array $users
-   * @tag 1
-   * @label optional
-   * @type ProtocolBuffers::TYPE_MESSAGE
-   * @see TestUser
-   **/
-  protected $users;
-  
-  
-  // @@protoc_insertion_point(properties_scope:.TestMessage)
-
-  // @@protoc_insertion_point(class_scope:.TestMessage)
-
-  /**
-   * get descriptor for protocol buffers
-   * 
-   * @return ProtocolBuffersDescriptor
-   */
-  public static function getDescriptor()
-  {
-    static $descriptor;
-    
-    if (!isset($descriptor)) {
-      $desc = new ProtocolBuffersDescriptorBuilder();
-      $desc->addField(1, new ProtocolBuffersFieldDescriptor(array(
-        "type"     => ProtocolBuffers::TYPE_MESSAGE,
-        "name"     => "users",
-        "required" => false,
-        "optional" => false,
-        "repeated" => true,
-        "packable" => false,
-        "default"  => null,
-        "message" => 'TestUser',
-      )));
-      // @@protoc_insertion_point(builder_scope:.TestMessage)
-
-      $descriptor = $desc->build();
-    }
-    return $descriptor;
-  }
-
-}
-
-// @@protoc_insertion_point(namespace:.TestUser)
-
-/**
- * Generated by the protocol buffer compiler.  DO NOT EDIT!
- * source: x.proto
- *
- * -*- magic methods -*-
- *
- * @method string getId()
- * @method void setId(string $value)
- */
-class TestUser extends ProtocolBuffersMessage
-{
-    // @@protoc_insertion_point(traits:.TestUser)
-
-    /**
-     * @var string $id
-     * @tag 1
-     * @label required
-     * @type ProtocolBuffers::TYPE_INT64
-     **/
-    protected $id;
-
-
-    // @@protoc_insertion_point(properties_scope:.TestUser)
-
-    // @@protoc_insertion_point(class_scope:.TestUser)
-
-    /**
-     * get descriptor for protocol buffers
-     *
-     * @return ProtocolBuffersDescriptor
-     */
-    public static function getDescriptor()
-    {
-        static $descriptor;
-
-        if (!isset($descriptor)) {
-            $desc = new ProtocolBuffersDescriptorBuilder();
-            $desc->addField(1, new ProtocolBuffersFieldDescriptor(array(
-                "type"     => ProtocolBuffers::TYPE_INT64,
-                "name"     => "id",
-                "required" => true,
-                "optional" => false,
-                "repeated" => false,
-                "packable" => false,
-                "default"  => null,
-            )));
-            // @@protoc_insertion_point(builder_scope:.TestUser)
-
-            $descriptor = $desc->build();
-        }
-        return $descriptor;
-    }
-
-}
-
-$bar = new TestMessage(array('users' => array(
-    new TestUser(array('id' => 1)),
-    new TestUser(array('id' => 2)),
-    new TestUser(array('id' => 3))
-)));
-
-foreach ($bar->getUsers() as $user) {
-	echo $user->getId() . PHP_EOL;
-}
-
-$bar = new TestMessage(array('users' => array(
-    array('id' => 1),
-    array('id' => 2),
-    array('id' => 3),
-)));
-
-foreach ($bar->getUsers() as $user) {
-	echo $user->getId() . PHP_EOL;
-}
-
-$u1 = new TestUser(array('id' => 1));
-$u2 = new TestUser(array('id' => 2));
-$u3 = new TestUser(array('id' => 3));
-$users = array($u1, $u2, $u3);
-
-$bar = new TestMessage(array('users' => $users));
-foreach ($bar->getUsers() as $user) {
-	echo $user->getId() . PHP_EOL;
-}
-
-try {
-$var = new TestMessage(array('users' => array(
-		array('id' => 1),
-    new StdClass(),
-)));
-	echo "FAULT" . PHP_EOL;
-} catch (InvalidArgumentException $e) {
-	echo "OK" . PHP_EOL;
-}
---EXPECT--
-1
-2
-3
-1
-2
-3
-1
-2
-3
-OK
\ No newline at end of file
diff --git a/tests/conformance/CmakeLists.txt b/tests/conformance/CmakeLists.txt
deleted file mode 100644
index d5401ee..0000000
--- a/tests/conformance/CmakeLists.txt
+++ /dev/null
@@ -1,89 +0,0 @@
-cmake_minimum_required(VERSION 2.8)
-
-INCLUDE(FindProtobuf)
-FIND_PACKAGE(Protobuf REQUIRED)
-
-# Gtest source archive to use
-SET(GTEST_ARCHIVE gtest-1.7.0.zip)
-# Where to download archive (if it doesn't exist)
-SET(GTEST_DLSERVER http://googletest.googlecode.com/files)
-SET(GTEST_ROOT $ENV{HOME}/Downloads/gtest-1.7.0)
-
-function(PROTOBUF_GENERATE_PHP SRCS)
-  if(NOT ARGN)
-    message(SEND_ERROR "Error: PROTOBUF_GENERATE_PHP() called without any proto files")
-    return()
-  endif(NOT ARGN)
-
-  if(PROTOBUF_GENERATE_PHP_APPEND_PATH)
-    # Create an include path for each file specified
-    foreach(FIL ${ARGN})
-      get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
-      get_filename_component(ABS_PATH ${ABS_FIL} PATH)
-      list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
-      if(${_contains_already} EQUAL -1)
-          list(APPEND _protobuf_include_path -I ${ABS_PATH})
-      endif()
-    endforeach()
-  else()
-    set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR})
-  endif()
-
-  set(${SRCS})
-  foreach(FIL ${ARGN})
-    get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
-    get_filename_component(FIL_WE ${FIL} NAME_WE)
-
-    list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.proto.php")
-    add_custom_command(
-      OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.proto.php"
-      COMMAND  ${PROTOBUF_PROTOC_EXECUTABLE}
-      ARGS --plugin /usr/local/bin/protoc-gen-php --php_out ${CMAKE_CURRENT_BINARY_DIR} ${_protobuf_include_path}  ${ABS_FIL}
-      DEPENDS ${ABS_FIL}
-      COMMENT "Running PHP protocol buffer compiler on ${FIL}"
-      VERBATIM )
-    add_custom_target(protoc-gen-php ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.proto.php")
-  endforeach()
-
-  set_source_files_properties(${${SRCS}} PROPERTIES GENERATED TRUE)
-  set(${SRCS} ${${SRCS}} PARENT_SCOPE)
-endfunction()
-
-IF(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${GTEST_ARCHIVE})
-	MESSAGE("Downloading file: ${CMAKE_SOURCE_DIR}/${GTEST_ARCHIVE}")
-	FILE(DOWNLOAD ${GTEST_DLSERVER}/${GTEST_ARCHIVE}
-		${CMAKE_CURRENT_BINARY_DIR}/${GTEST_ARCHIVE})
-
-	EXECUTE_PROCESS(COMMAND cmake -E tar zxf ${GTEST_ARCHIVE}
-		WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
-
-	ADD_SUBDIRECTORY(${CMAKE_CURRENT_BINARY_DIR}/gtest-1.7.0 gtest-1.7.0)
-	INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/include ${CMAKE_CURRENT_BINARY_DIR})
-ENDIF(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${GTEST_ARCHIVE})
-
-FILE(GLOB ProtoFiles "${CMAKE_CURRENT_SOURCE_DIR}/proto/*.proto")
-
-PROTOBUF_GENERATE_PHP(ProtoPHP ${ProtoFiles})
-MESSAGE("Generated file: ${ProtoPHP}")
-PROTOBUF_GENERATE_CPP(ProtoSources ProtoHeaders ${ProtoFiles})
-MESSAGE("Generated file: ${ProtoSources}")
-
-INCLUDE_DIRECTORIES(
-    ${GTEST_ROOT}/include
-    ${PROTOBUF_INCLUDE_DIR}
-    ${CMAKE_CURRENT_BINARY_DIR}
-)
-
-FILE(GLOB SRC_TESTS *.cc)
-
-ADD_EXECUTABLE(conformance_test
-	${SRC_TESTS}
-	${ProtoSources}
-)
-
-TARGET_LINK_LIBRARIES(conformance_test
-    pthread
-    ${GTEST_ROOT}/build/libgtest.a
-    ${GTEST_ROOT}/build/libgtest_main.a
-    ${PROTOBUF_LIBRARY}
-)
diff --git a/tests/conformance/conformance_test.cc b/tests/conformance/conformance_test.cc
deleted file mode 100644
index a0cf4bf..0000000
--- a/tests/conformance/conformance_test.cc
+++ /dev/null
@@ -1,80 +0,0 @@
-#include <iostream>
-#include <fstream>
-#include <string>
-#include <gtest/gtest.h>
-#include "message_sint32.pb.h"
-
-using namespace std;
-
-int add(int x, int y)
-{
-    return x + y;
-}
-
-TEST(AddTest, Test1)
-{
-    chobie::github::io::Field message;
-    chobie::github::io::Field r;
-
-
-    message.set_v_double(3.14);
-    message.set_v_float(3.14);
-    message.set_v_int64(0x7FFFFFFFFFFFFFFF);//0x8000000000000000
-    message.set_v_uint64(0xFFFFFFFFFFFFFFFF);
-    message.set_v_int32(0x7FFFFFFF);//0x80000000
-    message.set_v_fixed64(0xFFFFFFFFFFFFFFFF);
-    message.set_v_fixed32(0xFFFFFFFF);
-    message.set_v_bool(true);
-
-    message.set_v_uint32(0xFFFFFFFF);
-    message.set_v_sfixed32(0x7FFFFFFF);
-    message.set_v_sfixed64(0x7FFFFFFFFFFFFFFF);
-    message.set_v_sint32(0x7FFFFFFF);
-    message.set_v_sint64(0x7FFFFFFFFFFFFFFF);
-    message.set_v_string("Hello World");
-
-    message.set_v_int64_min(0x8000000000000000);
-    message.set_v_int32_min(0x80000000);
-    message.set_v_sfixed32_min(0x80000000);
-    message.set_v_sfixed64_min(0x8000000000000000);
-    message.set_v_sint32_min(0x80000000);
-    message.set_v_sint64_min(0x8000000000000000);
-
-    string result;
-
-    message.SerializeToString(&result);
-    fstream input("result.bin", ios::in | ios::binary);
-    //r.ParseFromString(result);
-    r.ParseFromIstream(&input);
-
-
-    cout << "double: " << r.v_double() << endl;
-    cout << "float: " << r.v_float() << endl;
-    cout << "int64: " << r.v_int64() << endl;
-    cout << "uint64: " << r.v_uint64() << endl;
-    cout << "int32: " << r.v_int32() << endl;
-    cout << "fixed64: " << r.v_fixed64() << endl;
-    cout << "fixed32: " << r.v_fixed32() << endl;
-    cout << "bool: " << r.v_bool() << endl;
-    cout << "uint32: " << r.v_uint32() << endl;
-    cout << "sfixed32: " << r.v_sfixed32() << endl;
-    cout << "sfixed64: " << r.v_sfixed64() << endl;
-    cout << "sint32: " << r.v_sint32() << endl;
-    cout << "sint64: " << r.v_sint64() << endl;
-    cout << "string: " << r.v_string() << endl;
-
-    cout << "int64_min: " << r.v_int64_min() << endl;
-    cout << "int32_min: " << r.v_int32_min() << endl;
-    cout << "sfixed32_min: " << r.v_sfixed32_min() << endl;
-    cout << "sfixed64_min: " << r.v_sfixed64_min() << endl;
-    cout << "sint32_min: " << r.v_sint32_min() << endl;
-    cout << "sint64_min: " << r.v_sint64_min() << endl;
-
-    fstream output("test.bin", ios::out | ios::trunc | ios::binary);
-
-    if (!message.SerializeToOstream(&output)) {
-      cerr << "Failed to write address book." << endl;
-    }
-
-    ASSERT_EQ(2, add(1, 1));
-}
diff --git a/tests/conformance/proto/message_sint32.proto b/tests/conformance/proto/message_sint32.proto
deleted file mode 100644
index aed0bb0..0000000
--- a/tests/conformance/proto/message_sint32.proto
+++ /dev/null
@@ -1,27 +0,0 @@
-package chobie.github.io;
-
-message Field {
-	optional double v_double = 1;
-	optional float v_float = 2;
-	optional int64 v_int64 = 3;
-	optional uint64 v_uint64 = 4;
-	optional int32 v_int32 = 5;
-	optional fixed64 v_fixed64 = 6;
-	optional fixed32 v_fixed32 = 7;
-	optional bool v_bool = 8;
-	optional string v_string = 9;
-	optional bytes v_bytes = 12;
-	optional uint32 v_uint32 = 13;
-	optional sfixed32 v_sfixed32 = 15;
-	optional sfixed64 v_sfixed64 = 16;
-	optional sint32 v_sint32 = 17;
-	optional sint64 v_sint64 = 18;
-
-	optional int64 v_int64_min = 20;
-	optional int32 v_int32_min = 21;
-	optional sfixed32 v_sfixed32_min = 22;
-	optional sfixed64 v_sfixed64_min = 23;
-	optional sint32 v_sint32_min = 24;
-	optional sint64 v_sint64_min = 25;
-
-}
diff --git a/tests/integration/README.md b/tests/integration/README.md
deleted file mode 100644
index 0050ca7..0000000
--- a/tests/integration/README.md
+++ /dev/null
@@ -1,10 +0,0 @@
-SAPI Integration Test
-=====================
-
-```
-# run php-fpm
-composer install
-./vendor/bin/phpunit
-```
-
-these test cases checks php life cycles.
\ No newline at end of file
diff --git a/tests/integration/bootstrap.php b/tests/integration/bootstrap.php
deleted file mode 100644
index 6ee6de3..0000000
--- a/tests/integration/bootstrap.php
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-require 'vendor/autoload.php';
-
-use Adoy\FastCGI\Client;
-
-
-function fastcgi_get_contents($url)
-{
-    $url = parse_url($url);
-    if (!$url || !isset($url['path'])) {
-        die("Malformed URI");
-    }
-
-    $req = '/'.basename($url['path']);
-    if (isset($url['query'])) {
-        $uri = $req .'?'.$url['query'];
-    } else {
-        $url['query'] = '';
-        $uri = $req;
-    }
-    $client = new Client(
-        (isset($url['host']) ? $url['host'] : 'localhost'),
-        (isset($url['port']) ? $url['port'] : 9000));
-
-    $params = array(
-        'GATEWAY_INTERFACE' => 'FastCGI/1.0',
-        'REQUEST_METHOD'    => 'GET',
-        'SCRIPT_FILENAME'   => $url['path'],
-        'SCRIPT_NAME'       => $req,
-        'QUERY_STRING'      => $url['query'],
-        'REQUEST_URI'       => $uri,
-        'DOCUMENT_URI'      => $req,
-        'SERVER_SOFTWARE'   => 'php/fcgiclient',
-        'REMOTE_ADDR'       => '127.0.0.1',
-        'REMOTE_PORT'       => '9985',
-        'SERVER_ADDR'       => '127.0.0.1',
-        'SERVER_PORT'       => '80',
-        'SERVER_NAME'       => php_uname('n'),
-        'SERVER_PROTOCOL'   => 'HTTP/1.1',
-        'CONTENT_TYPE'      => '',
-        'CONTENT_LENGTH'    => 0
-    );
-
-    return $client->request($params, false);
-}
\ No newline at end of file
diff --git a/tests/integration/composer.json b/tests/integration/composer.json
deleted file mode 100644
index 61ce31f..0000000
--- a/tests/integration/composer.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
-    "require": {
-        "adoy/fastcgi-client": "dev-master",
-        "phpunit/phpunit": "3.7.*"
-    },
-    "autoload": {
-        "psr-4": {"pecl\\": "messages/pecl"}
-    }
-}
diff --git a/tests/integration/composer.lock b/tests/integration/composer.lock
deleted file mode 100644
index 14684ca..0000000
--- a/tests/integration/composer.lock
+++ /dev/null
@@ -1,477 +0,0 @@
-{
-    "_readme": [
-        "This file locks the dependencies of your project to a known state",
-        "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
-    ],
-    "hash": "f67e59bc60417467fc1fc8381b27d514",
-    "packages": [
-        {
-            "name": "adoy/fastcgi-client",
-            "version": "dev-master",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/adoy/PHP-FastCGI-Client.git",
-                "reference": "ff2bffb159934de30e43955ceb01c9dc30078d0e"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/adoy/PHP-FastCGI-Client/zipball/ff2bffb159934de30e43955ceb01c9dc30078d0e",
-                "reference": "ff2bffb159934de30e43955ceb01c9dc30078d0e",
-                "shasum": ""
-            },
-            "type": "library",
-            "autoload": {
-                "psr-0": {
-                    "Adoy\\FastCGI\\": "src"
-                }
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "MIT"
-            ],
-            "authors": [
-                {
-                    "name": "Pierrick Charron",
-                    "email": "pierrick@adoy.net"
-                }
-            ],
-            "description": "Client for communication with a FastCGI (FCGI) application using the FastCGI protocol.",
-            "keywords": [
-                "fastcgi"
-            ],
-            "time": "2014-03-07 16:37:37"
-        },
-        {
-            "name": "phpunit/php-code-coverage",
-            "version": "1.2.17",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/sebastianbergmann/php-code-coverage.git",
-                "reference": "6ef2bf3a1c47eca07ea95f0d8a902a6340390b34"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/6ef2bf3a1c47eca07ea95f0d8a902a6340390b34",
-                "reference": "6ef2bf3a1c47eca07ea95f0d8a902a6340390b34",
-                "shasum": ""
-            },
-            "require": {
-                "php": ">=5.3.3",
-                "phpunit/php-file-iterator": ">=1.3.0@stable",
-                "phpunit/php-text-template": ">=1.2.0@stable",
-                "phpunit/php-token-stream": ">=1.1.3@stable"
-            },
-            "require-dev": {
-                "phpunit/phpunit": "3.7.*@dev"
-            },
-            "suggest": {
-                "ext-dom": "*",
-                "ext-xdebug": ">=2.0.5"
-            },
-            "type": "library",
-            "extra": {
-                "branch-alias": {
-                    "dev-master": "1.2.x-dev"
-                }
-            },
-            "autoload": {
-                "classmap": [
-                    "PHP/"
-                ]
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "include-path": [
-                ""
-            ],
-            "license": [
-                "BSD-3-Clause"
-            ],
-            "authors": [
-                {
-                    "name": "Sebastian Bergmann",
-                    "email": "sb@sebastian-bergmann.de",
-                    "role": "lead"
-                }
-            ],
-            "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.",
-            "homepage": "https://github.com/sebastianbergmann/php-code-coverage",
-            "keywords": [
-                "coverage",
-                "testing",
-                "xunit"
-            ],
-            "time": "2014-03-28 10:53:45"
-        },
-        {
-            "name": "phpunit/php-file-iterator",
-            "version": "1.3.4",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/sebastianbergmann/php-file-iterator.git",
-                "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb",
-                "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb",
-                "shasum": ""
-            },
-            "require": {
-                "php": ">=5.3.3"
-            },
-            "type": "library",
-            "autoload": {
-                "classmap": [
-                    "File/"
-                ]
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "include-path": [
-                ""
-            ],
-            "license": [
-                "BSD-3-Clause"
-            ],
-            "authors": [
-                {
-                    "name": "Sebastian Bergmann",
-                    "email": "sb@sebastian-bergmann.de",
-                    "role": "lead"
-                }
-            ],
-            "description": "FilterIterator implementation that filters files based on a list of suffixes.",
-            "homepage": "https://github.com/sebastianbergmann/php-file-iterator/",
-            "keywords": [
-                "filesystem",
-                "iterator"
-            ],
-            "time": "2013-10-10 15:34:57"
-        },
-        {
-            "name": "phpunit/php-text-template",
-            "version": "1.2.0",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/sebastianbergmann/php-text-template.git",
-                "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a",
-                "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a",
-                "shasum": ""
-            },
-            "require": {
-                "php": ">=5.3.3"
-            },
-            "type": "library",
-            "autoload": {
-                "classmap": [
-                    "Text/"
-                ]
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "include-path": [
-                ""
-            ],
-            "license": [
-                "BSD-3-Clause"
-            ],
-            "authors": [
-                {
-                    "name": "Sebastian Bergmann",
-                    "email": "sb@sebastian-bergmann.de",
-                    "role": "lead"
-                }
-            ],
-            "description": "Simple template engine.",
-            "homepage": "https://github.com/sebastianbergmann/php-text-template/",
-            "keywords": [
-                "template"
-            ],
-            "time": "2014-01-30 17:20:04"
-        },
-        {
-            "name": "phpunit/php-timer",
-            "version": "1.0.5",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/sebastianbergmann/php-timer.git",
-                "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c",
-                "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c",
-                "shasum": ""
-            },
-            "require": {
-                "php": ">=5.3.3"
-            },
-            "type": "library",
-            "autoload": {
-                "classmap": [
-                    "PHP/"
-                ]
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "include-path": [
-                ""
-            ],
-            "license": [
-                "BSD-3-Clause"
-            ],
-            "authors": [
-                {
-                    "name": "Sebastian Bergmann",
-                    "email": "sb@sebastian-bergmann.de",
-                    "role": "lead"
-                }
-            ],
-            "description": "Utility class for timing",
-            "homepage": "https://github.com/sebastianbergmann/php-timer/",
-            "keywords": [
-                "timer"
-            ],
-            "time": "2013-08-02 07:42:54"
-        },
-        {
-            "name": "phpunit/php-token-stream",
-            "version": "1.2.2",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/sebastianbergmann/php-token-stream.git",
-                "reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/ad4e1e23ae01b483c16f600ff1bebec184588e32",
-                "reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32",
-                "shasum": ""
-            },
-            "require": {
-                "ext-tokenizer": "*",
-                "php": ">=5.3.3"
-            },
-            "type": "library",
-            "extra": {
-                "branch-alias": {
-                    "dev-master": "1.2-dev"
-                }
-            },
-            "autoload": {
-                "classmap": [
-                    "PHP/"
-                ]
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "include-path": [
-                ""
-            ],
-            "license": [
-                "BSD-3-Clause"
-            ],
-            "authors": [
-                {
-                    "name": "Sebastian Bergmann",
-                    "email": "sb@sebastian-bergmann.de",
-                    "role": "lead"
-                }
-            ],
-            "description": "Wrapper around PHP's tokenizer extension.",
-            "homepage": "https://github.com/sebastianbergmann/php-token-stream/",
-            "keywords": [
-                "tokenizer"
-            ],
-            "time": "2014-03-03 05:10:30"
-        },
-        {
-            "name": "phpunit/phpunit",
-            "version": "3.7.35",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/sebastianbergmann/phpunit.git",
-                "reference": "83f9537e46346f75ed6925441ac259453213c7cc"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/83f9537e46346f75ed6925441ac259453213c7cc",
-                "reference": "83f9537e46346f75ed6925441ac259453213c7cc",
-                "shasum": ""
-            },
-            "require": {
-                "ext-dom": "*",
-                "ext-pcre": "*",
-                "ext-reflection": "*",
-                "ext-spl": "*",
-                "php": ">=5.3.3",
-                "phpunit/php-code-coverage": "~1.2",
-                "phpunit/php-file-iterator": "~1.3",
-                "phpunit/php-text-template": "~1.1",
-                "phpunit/php-timer": "~1.0",
-                "phpunit/phpunit-mock-objects": "~1.2",
-                "symfony/yaml": "~2.0"
-            },
-            "require-dev": {
-                "pear-pear.php.net/pear": "1.9.4"
-            },
-            "suggest": {
-                "ext-json": "*",
-                "ext-simplexml": "*",
-                "ext-tokenizer": "*",
-                "phpunit/php-invoker": "~1.1"
-            },
-            "bin": [
-                "composer/bin/phpunit"
-            ],
-            "type": "library",
-            "extra": {
-                "branch-alias": {
-                    "dev-master": "3.7.x-dev"
-                }
-            },
-            "autoload": {
-                "classmap": [
-                    "PHPUnit/"
-                ]
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "include-path": [
-                "",
-                "../../symfony/yaml/"
-            ],
-            "license": [
-                "BSD-3-Clause"
-            ],
-            "authors": [
-                {
-                    "name": "Sebastian Bergmann",
-                    "email": "sebastian@phpunit.de",
-                    "role": "lead"
-                }
-            ],
-            "description": "The PHP Unit Testing framework.",
-            "homepage": "http://www.phpunit.de/",
-            "keywords": [
-                "phpunit",
-                "testing",
-                "xunit"
-            ],
-            "time": "2014-04-21 06:25:54"
-        },
-        {
-            "name": "phpunit/phpunit-mock-objects",
-            "version": "1.2.3",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
-                "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/5794e3c5c5ba0fb037b11d8151add2a07fa82875",
-                "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875",
-                "shasum": ""
-            },
-            "require": {
-                "php": ">=5.3.3",
-                "phpunit/php-text-template": ">=1.1.1@stable"
-            },
-            "suggest": {
-                "ext-soap": "*"
-            },
-            "type": "library",
-            "autoload": {
-                "classmap": [
-                    "PHPUnit/"
-                ]
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "include-path": [
-                ""
-            ],
-            "license": [
-                "BSD-3-Clause"
-            ],
-            "authors": [
-                {
-                    "name": "Sebastian Bergmann",
-                    "email": "sb@sebastian-bergmann.de",
-                    "role": "lead"
-                }
-            ],
-            "description": "Mock Object library for PHPUnit",
-            "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/",
-            "keywords": [
-                "mock",
-                "xunit"
-            ],
-            "time": "2013-01-13 10:24:48"
-        },
-        {
-            "name": "symfony/yaml",
-            "version": "v2.4.4",
-            "target-dir": "Symfony/Component/Yaml",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/symfony/Yaml.git",
-                "reference": "65539ecde838f9c0d18b006b2101e3deb4b5c9ff"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/symfony/Yaml/zipball/65539ecde838f9c0d18b006b2101e3deb4b5c9ff",
-                "reference": "65539ecde838f9c0d18b006b2101e3deb4b5c9ff",
-                "shasum": ""
-            },
-            "require": {
-                "php": ">=5.3.3"
-            },
-            "type": "library",
-            "extra": {
-                "branch-alias": {
-                    "dev-master": "2.4-dev"
-                }
-            },
-            "autoload": {
-                "psr-0": {
-                    "Symfony\\Component\\Yaml\\": ""
-                }
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "MIT"
-            ],
-            "authors": [
-                {
-                    "name": "Fabien Potencier",
-                    "email": "fabien@symfony.com",
-                    "homepage": "http://fabien.potencier.org",
-                    "role": "Lead Developer"
-                },
-                {
-                    "name": "Symfony Community",
-                    "homepage": "http://symfony.com/contributors"
-                }
-            ],
-            "description": "Symfony Yaml Component",
-            "homepage": "http://symfony.com",
-            "time": "2014-04-18 20:37:09"
-        }
-    ],
-    "packages-dev": [
-
-    ],
-    "aliases": [
-
-    ],
-    "minimum-stability": "stable",
-    "stability-flags": {
-        "adoy/fastcgi-client": 20
-    },
-    "platform": [
-
-    ],
-    "platform-dev": [
-
-    ]
-}
diff --git a/tests/integration/messages/autoload.php b/tests/integration/messages/autoload.php
deleted file mode 100644
index 170e2b1..0000000
--- a/tests/integration/messages/autoload.php
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php
-spl_autoload_register(function($name){
-  static $classmap;
-  if (!$classmap) {
-    $classmap = array(
-      'pecl\protocolbuffers\User' => '/pecl/protocolbuffers/User.php',
-      // @@protoc_insertion_point(autoloader_scope:classmap)
-    );
-  }
-  if (isset($classmap[$name])) {
-    require __DIR__ . DIRECTORY_SEPARATOR . $classmap[$name];
-  }
-});
-
-call_user_func(function(){
-  $registry = \ProtocolBuffers\ExtensionRegistry::getInstance();
-  // @@protoc_insertion_point(extension_scope:registry)
-});
diff --git a/tests/integration/messages/pecl/protocolbuffers/User.php b/tests/integration/messages/pecl/protocolbuffers/User.php
deleted file mode 100644
index 280464c..0000000
--- a/tests/integration/messages/pecl/protocolbuffers/User.php
+++ /dev/null
@@ -1,78 +0,0 @@
-<?php
-namespace pecl\protocolbuffers;
-
-// @@protoc_insertion_point(namespace:.pecl.protocolbuffers.User)
-
-/**
- * Generated by the protocol buffer compiler.  DO NOT EDIT!
- * source: proto/user.proto
- *
- * -*- magic methods -*-
- *
- * @method string getUserId()
- * @method void setUserId(string $value)
- * @method string getName()
- * @method void setName(string $value)
- */
-class User extends \ProtocolBuffers\Message
-{
-  // @@protoc_insertion_point(traits:.pecl.protocolbuffers.User)
-  
-  /**
-   * @var string $user_id
-   * @tag 1
-   * @label optional
-   * @type \ProtocolBuffers::TYPE_INT64
-   **/
-  protected $user_id;
-  
-  /**
-   * @var string $name
-   * @tag 2
-   * @label optional
-   * @type \ProtocolBuffers::TYPE_BYTES
-   **/
-  protected $name;
-  
-  
-  // @@protoc_insertion_point(properties_scope:.pecl.protocolbuffers.User)
-
-  // @@protoc_insertion_point(class_scope:.pecl.protocolbuffers.User)
-
-  /**
-   * get descriptor for protocol buffers
-   * 
-   * @return \ProtocolBuffersDescriptor
-   */
-  public static function getDescriptor()
-  {
-    static $descriptor;
-    
-    if (!isset($descriptor)) {
-      $desc = new \ProtocolBuffers\DescriptorBuilder();
-      $desc->addField(1, new \ProtocolBuffers\FieldDescriptor(array(
-        "type"     => \ProtocolBuffers::TYPE_INT64,
-        "name"     => "user_id",
-        "required" => false,
-        "optional" => true,
-        "repeated" => false,
-        "packable" => false,
-        "default"  => null,
-      )));
-      $desc->addField(2, new \ProtocolBuffers\FieldDescriptor(array(
-        "type"     => \ProtocolBuffers::TYPE_BYTES,
-        "name"     => "name",
-        "required" => false,
-        "optional" => true,
-        "repeated" => false,
-        "packable" => false,
-        "default"  => null,
-      )));
-      // @@protoc_insertion_point(builder_scope:.pecl.protocolbuffers.User)
-
-      $descriptor = $desc->build();
-    }
-    return $descriptor;
-  }
-
-}
diff --git a/tests/integration/messages/proto/user.proto.php b/tests/integration/messages/proto/user.proto.php
deleted file mode 100644
index 7b48c60..0000000
--- a/tests/integration/messages/proto/user.proto.php
+++ /dev/null
@@ -1,2 +0,0 @@
-<?php
-require_once __DIR__ . DIRECTORY_SEPARATOR . 'autoload.php';
diff --git a/tests/integration/php-fpm.conf b/tests/integration/php-fpm.conf
deleted file mode 100644
index c3da917..0000000
--- a/tests/integration/php-fpm.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-[global]
-error_log = /home/travis/build/php-fpm.log
-log_level = debug
-
-[www]
-user = nobody
-group = nogroup
-listen = 127.0.0.1:9000
-
-pm = static
-pm.max_children = 1
-pm.max_requests = 0
-request_terminate_timeout = 30
\ No newline at end of file
diff --git a/tests/integration/phpunit.xml.dist b/tests/integration/phpunit.xml.dist
deleted file mode 100644
index e884d92..0000000
--- a/tests/integration/phpunit.xml.dist
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<phpunit backupGlobals="true"
-         backupStaticAttributes="false"
-         bootstrap="bootstrap.php"
-         colors="true"
-         convertErrorsToExceptions="true"
-         convertNoticesToExceptions="false"
-         convertWarningsToExceptions="false"
-         processIsolation="false"
-         stopOnError="false"
-         stopOnFailure="false"
-         stopOnIncomplete="false"
-         stopOnSkipped="false"
-         syntaxCheck="true"
-         strict="true"
-         verbose="true">
-    <php>
-        <ini name="date.timezone" value="Asia/Tokyo" />
-    </php>
-    <testsuites>
-        <testsuite name="PECL ProtocolBuffers Integration tests">
-            <directory>tests</directory>
-        </testsuite>
-    </testsuites>
-</phpunit>
\ No newline at end of file
diff --git a/tests/integration/proto/user.proto b/tests/integration/proto/user.proto
deleted file mode 100644
index db30817..0000000
--- a/tests/integration/proto/user.proto
+++ /dev/null
@@ -1,7 +0,0 @@
-package pecl.protocolbuffers;
-
-message User
-{
-	optional int64 user_id = 1;
-	optional bytes name = 2;
-}
\ No newline at end of file
diff --git a/tests/integration/protocolbuffers.ini b/tests/integration/protocolbuffers.ini
deleted file mode 100644
index a7954da..0000000
--- a/tests/integration/protocolbuffers.ini
+++ /dev/null
@@ -1 +0,0 @@
-extension=protocolbuffers.so
\ No newline at end of file
diff --git a/tests/integration/src/MultipleRequest.php b/tests/integration/src/MultipleRequest.php
deleted file mode 100644
index cd5066d..0000000
--- a/tests/integration/src/MultipleRequest.php
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php
-require dirname(__DIR__) . DIRECTORY_SEPARATOR . "bootstrap.php";
-
-$user = new pecl\protocolbuffers\User();
-$user->setUserId(12345);
-$user->setName("chobie");
-echo $user->serializeToString();
\ No newline at end of file
diff --git a/tests/integration/test.php b/tests/integration/test.php
deleted file mode 100644
index 52347a1..0000000
--- a/tests/integration/test.php
+++ /dev/null
@@ -1,2 +0,0 @@
-<?php
-echo "Hello";
diff --git a/tests/integration/tests/MultipleRequestTest.php b/tests/integration/tests/MultipleRequestTest.php
deleted file mode 100644
index 1bff910..0000000
--- a/tests/integration/tests/MultipleRequestTest.php
+++ /dev/null
@@ -1,17 +0,0 @@
-<?php
-
-class MultipleRequestTest extends PHPUnit_Framework_TestCase
-{
-    public function testRequest()
-    {
-        $data = fastcgi_get_contents("localhost:9000/home/travis/build/chobie/php-protocolbuffers/tests/integration/src/MultipleRequest.php");
-        // NOTE(chobie): check segmentation fault
-        $data = fastcgi_get_contents("localhost:9000/home/travis/build/chobie/php-protocolbuffers/tests/integration/src/MultipleRequest.php");
-
-        list($_, $body) = preg_split("/\r?\n\r?\n/", $data, 2);
-        $user = \pecl\protocolbuffers\User::parseFromString($body);
-        $this->assertInstanceOf('\pecl\protocolbuffers\User', $user);
-        $this->assertEquals("12345", $user->getUserId());
-        $this->assertEquals("chobie", $user->getName());
-    }
-}
\ No newline at end of file

From 818f996466c4eea47fb703a4ec711860c8abd9f3 Mon Sep 17 00:00:00 2001
From: hellofreedom <liudezhiabc@126.com>
Date: Sat, 9 May 2015 22:45:35 +0800
Subject: [PATCH 4/4] format

---
 config.m4         |  17 +-
 protocolbuffers.c | 462 +++++++++++++++++++++++-----------------------
 protocolbuffers.h | 254 ++++++++++++-------------
 3 files changed, 365 insertions(+), 368 deletions(-)

diff --git a/config.m4 b/config.m4
index ab3c4a3..865c4d8 100644
--- a/config.m4
+++ b/config.m4
@@ -1,22 +1,19 @@
-PHP_ARG_ENABLE(protocolbuffers, Whether to enable the "protocolbuffers" extension,
-    [ --enable-protocolbuffers  Enable "protocolbuffers" extension support])
+PHP_ARG_ENABLE(protocolbuffers, whether to enable protocolbuffers extension,
+[  --enable-protocolbuffers  Enable protocolbuffers extension support])
 
-PHP_ARG_ENABLE(protocolbuffers-debug, for protocolbuffers debug support,
-    [ --enable-protocolbuffers-debug       Enable enable protocolbuffers debug support], no, no)
+PHP_ARG_ENABLE(protocolbuffers-debug, whether to enable protocolbuffers extension debug support,
+[  --enable-protocolbuffers-debug  Enable protocolbuffers extension debug support], no, no)
 
 if test $PHP_PROTOCOLBUFFERS != "no"; then
     if test "$PHP_PROTOCOLBUFFERS_DEBUG" != "no"; then
         CFLAGS="$CFLAGS -Wall -g -ggdb -O0 -DPHP_PROTOCOLBUFFERS_DEBUG=1"
         AC_DEFINE(PHP_PROTOCOLBUFFERS_DEBUG, 1, [Enable protocolbuffers debug support])
     else
-        //CFLAGS="$CFLAGS -Wall -g -ggdb -O0 -Wunused-variable -Wpointer-sign -Wimplicit-function-declaration -Winline -Wunused-macros -Wredundant-decls -Wstrict-aliasing=2 -Wswitch-enum -Wdeclaration-after-statement"
+        CFLAGS="$CFLAGS -Wall -g -ggdb -O0 -Wunused-variable -Wpointer-sign -Wimplicit-function-declaration -Winline -Wunused-macros -Wredundant-decls -Wstrict-aliasing=2 -Wswitch-enum -Wdeclaration-after-statement"
     fi
 
-    PHP_PROTOBUF_SRCS="protocolbuffers.c descriptor.c descriptor_builder.c field_descriptor.c message.c message_options.c enum.c enum_descriptor.c enum_value_descriptor.c enum_descriptor_builder.c php_message_options.c unknown_field.c unknown_field_set.c helper.c extension_registry.c core.c serializer.c json_serializer.c"
-
-    PHP_SUBST(PROTOCOLBUFFERS_SHARED_LIBADD)
-    PHP_NEW_EXTENSION(protocolbuffers, $PHP_PROTOBUF_SRCS, $ext_shared)
+    PHP_NEW_EXTENSION(protocolbuffers, protocolbuffers.c descriptor.c descriptor_builder.c field_descriptor.c message.c message_options.c enum.c enum_descriptor.c enum_value_descriptor.c enum_descriptor_builder.c php_message_options.c unknown_field.c unknown_field_set.c helper.c extension_registry.c core.c serializer.c json_serializer.c, $ext_shared)
     PHP_ADD_EXTENSION_DEP(protocolbuffers, spl, true)
-
+    PHP_SUBST(PROTOCOLBUFFERS_SHARED_LIBADD)
     PHP_SUBST([CFLAGS])
 fi
diff --git a/protocolbuffers.c b/protocolbuffers.c
index 9114d87..2f42d49 100644
--- a/protocolbuffers.c
+++ b/protocolbuffers.c
@@ -77,46 +77,46 @@ ZEND_DECLARE_MODULE_GLOBALS(protocolbuffers);
 zend_class_entry *php_protocolbuffers_get_exception_base(TSRMLS_D)
 {
 #if (PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION < 2)
-	return zend_exception_get_default();
+    return zend_exception_get_default();
 #else
-	return zend_exception_get_default(TSRMLS_C);
+    return zend_exception_get_default(TSRMLS_C);
 #endif
 }
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_protocolbuffers_decode, 0, 0, 1)
-	ZEND_ARG_INFO(0, class_name)
-	ZEND_ARG_INFO(0, bytes)
-	ZEND_ARG_INFO(0, descriptor)
+    ZEND_ARG_INFO(0, class_name)
+    ZEND_ARG_INFO(0, bytes)
+    ZEND_ARG_INFO(0, descriptor)
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_protocolbuffers_encode, 0, 0, 1)
-	ZEND_ARG_INFO(0, object)
-	ZEND_ARG_INFO(0, descriptor)
+    ZEND_ARG_INFO(0, object)
+    ZEND_ARG_INFO(0, descriptor)
 ZEND_END_ARG_INFO()
 
 /* {{{ proto mixed ProtocolBuffers::decode($class_name, $bytes)
 */
 PHP_METHOD(protocolbuffers, decode)
 {
-	char *klass;
-	const char *data;
-	long klass_len = 0, data_len = 0;
-
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
-		"ss", &klass, &klass_len, &data, &data_len) == FAILURE) {
-		return;
-	}
-
-	if (klass[0] == '\\') {
-		int x;
-		for (x = 0; x < klass_len-1; x++) {
-			klass[x] = klass[x+1];
-		}
-		klass[klass_len-1] = '\0';
-		klass_len--;
-	}
-
-	php_protocolbuffers_decode(INTERNAL_FUNCTION_PARAM_PASSTHRU, data, data_len, klass, klass_len);
+    char *klass;
+    const char *data;
+    long klass_len = 0, data_len = 0;
+
+    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
+        "ss", &klass, &klass_len, &data, &data_len) == FAILURE) {
+        return;
+    }
+
+    if (klass[0] == '\\') {
+        int x;
+        for (x = 0; x < klass_len-1; x++) {
+            klass[x] = klass[x+1];
+        }
+        klass[klass_len-1] = '\0';
+        klass_len--;
+    }
+
+    php_protocolbuffers_decode(INTERNAL_FUNCTION_PARAM_PASSTHRU, data, data_len, klass, klass_len);
 }
 /* }}} */
 
@@ -124,144 +124,144 @@ PHP_METHOD(protocolbuffers, decode)
 */
 PHP_METHOD(protocolbuffers, encode)
 {
-	zval *klass = NULL;
+    zval *klass = NULL;
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
-		"o", &klass) == FAILURE) {
-		return;
-	}
+    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
+        "o", &klass) == FAILURE) {
+        return;
+    }
 
-	php_protocolbuffers_encode(INTERNAL_FUNCTION_PARAM_PASSTHRU, Z_OBJCE_P(klass), klass);
+    php_protocolbuffers_encode(INTERNAL_FUNCTION_PARAM_PASSTHRU, Z_OBJCE_P(klass), klass);
 }
 /* }}} */
 
 static zend_function_entry php_protocolbuffers_methods[] = {
-	PHP_ME(protocolbuffers, decode, arginfo_protocolbuffers_decode, ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
-	PHP_ME(protocolbuffers, encode, NULL, ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
-	PHP_FE_END
+    PHP_ME(protocolbuffers, decode, arginfo_protocolbuffers_decode, ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
+    PHP_ME(protocolbuffers, encode, NULL, ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
+    PHP_FE_END
 };
 
 static void php_protocol_buffers_invalid_byte_sequence_exception(TSRMLS_D)
 {
-	zend_class_entry ce;
+    zend_class_entry ce;
 
-	INIT_CLASS_ENTRY(ce, "ProtocolBuffersInvalidByteSequenceException", 0);
-	php_protocol_buffers_invalid_byte_sequence_class_entry = zend_register_internal_class_ex(&ce, php_protocolbuffers_get_exception_base(TSRMLS_C), NULL TSRMLS_CC);
+    INIT_CLASS_ENTRY(ce, "ProtocolBuffersInvalidByteSequenceException", 0);
+    php_protocol_buffers_invalid_byte_sequence_class_entry = zend_register_internal_class_ex(&ce, php_protocolbuffers_get_exception_base(TSRMLS_C), NULL TSRMLS_CC);
 
-	PHP_PROTOCOLBUFFERS_REGISTER_NS_CLASS_ALIAS(PHP_PROTOCOLBUFFERS_NAMESPACE, "InvalidByteSequenceException", php_protocol_buffers_invalid_byte_sequence_class_entry);
+    PHP_PROTOCOLBUFFERS_REGISTER_NS_CLASS_ALIAS(PHP_PROTOCOLBUFFERS_NAMESPACE, "InvalidByteSequenceException", php_protocol_buffers_invalid_byte_sequence_class_entry);
 }
 
 static void php_protocol_buffers_invalid_exception(TSRMLS_D)
 {
-	zend_class_entry ce;
+    zend_class_entry ce;
 
-	INIT_CLASS_ENTRY(ce, "ProtocolBuffersInvalidProtocolBufferException", 0);
-	php_protocol_buffers_invalid_protocolbuffers_exception_class_entry = zend_register_internal_class_ex(&ce, php_protocolbuffers_get_exception_base(TSRMLS_C), NULL TSRMLS_CC);
+    INIT_CLASS_ENTRY(ce, "ProtocolBuffersInvalidProtocolBufferException", 0);
+    php_protocol_buffers_invalid_protocolbuffers_exception_class_entry = zend_register_internal_class_ex(&ce, php_protocolbuffers_get_exception_base(TSRMLS_C), NULL TSRMLS_CC);
 
-	PHP_PROTOCOLBUFFERS_REGISTER_NS_CLASS_ALIAS(PHP_PROTOCOLBUFFERS_NAMESPACE, "InvalidProtocolBufferException", php_protocol_buffers_invalid_protocolbuffers_exception_class_entry);
+    PHP_PROTOCOLBUFFERS_REGISTER_NS_CLASS_ALIAS(PHP_PROTOCOLBUFFERS_NAMESPACE, "InvalidProtocolBufferException", php_protocol_buffers_invalid_protocolbuffers_exception_class_entry);
 }
 
 static void php_protocolbuffers_uninitialized_message_exception(TSRMLS_D)
 {
-	zend_class_entry ce;
+    zend_class_entry ce;
 
-	INIT_CLASS_ENTRY(ce, "ProtocolBuffersUninitializedMessageException", 0);
-	php_protocol_buffers_uninitialized_message_exception_class_entry = zend_register_internal_class_ex(&ce, php_protocolbuffers_get_exception_base(TSRMLS_C), NULL TSRMLS_CC);
+    INIT_CLASS_ENTRY(ce, "ProtocolBuffersUninitializedMessageException", 0);
+    php_protocol_buffers_uninitialized_message_exception_class_entry = zend_register_internal_class_ex(&ce, php_protocolbuffers_get_exception_base(TSRMLS_C), NULL TSRMLS_CC);
 
-	PHP_PROTOCOLBUFFERS_REGISTER_NS_CLASS_ALIAS(PHP_PROTOCOLBUFFERS_NAMESPACE, "UninitializedMessageException", php_protocol_buffers_uninitialized_message_exception_class_entry);
+    PHP_PROTOCOLBUFFERS_REGISTER_NS_CLASS_ALIAS(PHP_PROTOCOLBUFFERS_NAMESPACE, "UninitializedMessageException", php_protocol_buffers_uninitialized_message_exception_class_entry);
 }
 
 static zend_function_entry php_protocolbuffers_describable_methods[] = {
-	ZEND_FENTRY(getDescriptor, NULL, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_ABSTRACT)
-	PHP_FE_END
+    ZEND_FENTRY(getDescriptor, NULL, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_ABSTRACT)
+    PHP_FE_END
 };
 
 static void php_protocol_buffers_serializable(TSRMLS_D)
 {
-	zend_class_entry ce;
+    zend_class_entry ce;
 
-	INIT_CLASS_ENTRY(ce, "ProtocolBuffersDescribable", php_protocolbuffers_describable_methods);
-	php_protocol_buffers_serializable_class_entry = zend_register_internal_interface(&ce TSRMLS_CC);
+    INIT_CLASS_ENTRY(ce, "ProtocolBuffersDescribable", php_protocolbuffers_describable_methods);
+    php_protocol_buffers_serializable_class_entry = zend_register_internal_interface(&ce TSRMLS_CC);
 
-	PHP_PROTOCOLBUFFERS_REGISTER_NS_CLASS_ALIAS(PHP_PROTOCOLBUFFERS_NAMESPACE, "Describable", php_protocol_buffers_serializable_class_entry);
+    PHP_PROTOCOLBUFFERS_REGISTER_NS_CLASS_ALIAS(PHP_PROTOCOLBUFFERS_NAMESPACE, "Describable", php_protocol_buffers_serializable_class_entry);
 }
 
 static zend_function_entry php_protocolbuffers_enum_describable_methods[] = {
-	ZEND_FENTRY(getEnumDescriptor, NULL, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_ABSTRACT)
-	PHP_FE_END
+    ZEND_FENTRY(getEnumDescriptor, NULL, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_ABSTRACT)
+    PHP_FE_END
 };
 
 static void php_protocol_buffers_enum_describable(TSRMLS_D)
 {
-	zend_class_entry ce;
+    zend_class_entry ce;
 
-	INIT_CLASS_ENTRY(ce, "ProtocolBuffersEnumDescribable", php_protocolbuffers_enum_describable_methods);
-	php_protocol_buffers_enum_describable_class_entry = zend_register_internal_interface(&ce TSRMLS_CC);
+    INIT_CLASS_ENTRY(ce, "ProtocolBuffersEnumDescribable", php_protocolbuffers_enum_describable_methods);
+    php_protocol_buffers_enum_describable_class_entry = zend_register_internal_interface(&ce TSRMLS_CC);
 
-	PHP_PROTOCOLBUFFERS_REGISTER_NS_CLASS_ALIAS(PHP_PROTOCOLBUFFERS_NAMESPACE, "EnumDescribable", php_protocol_buffers_serializable_class_entry);
+    PHP_PROTOCOLBUFFERS_REGISTER_NS_CLASS_ALIAS(PHP_PROTOCOLBUFFERS_NAMESPACE, "EnumDescribable", php_protocol_buffers_serializable_class_entry);
 }
 
 static void php_protocolbuffers_init(TSRMLS_D)
 {
-	zend_class_entry ce;
-
-	INIT_CLASS_ENTRY(ce, "ProtocolBuffers", php_protocolbuffers_methods);
-	protocol_buffers_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
-
-	php_protocol_buffers_invalid_byte_sequence_exception(TSRMLS_C);
-	php_protocol_buffers_invalid_exception(TSRMLS_C);
-	php_protocolbuffers_uninitialized_message_exception(TSRMLS_C);
-	php_protocolbuffers_descriptor_class(TSRMLS_C);
-	php_protocolbuffers_filed_descriptor_class(TSRMLS_C);
-	php_protocol_buffers_serializable(TSRMLS_C);
-	php_protocol_buffers_enum_describable(TSRMLS_C);
-	php_protocolbuffers_message_class(TSRMLS_C);
-	php_protocolbuffers_message_options_class(TSRMLS_C);
-	php_protocolbuffers_enum_class(TSRMLS_C);
-	php_protocolbuffers_enum_descriptor_class(TSRMLS_C);
-	php_protocolbuffers_enum_value_descriptor_class(TSRMLS_C);
-	php_protocolbuffers_enum_descriptor_builder_class(TSRMLS_C);
-	php_protocolbuffers_php_message_options_class(TSRMLS_C);
-	php_protocolbuffers_descriptor_builder_class(TSRMLS_C);
-	php_protocolbuffers_unknown_field_class(TSRMLS_C);
-	php_protocolbuffers_unknown_field_set_class(TSRMLS_C);
-	php_protocolbuffers_helper_class(TSRMLS_C);
-	php_protocolbuffers_extension_registry_class(TSRMLS_C);
+    zend_class_entry ce;
+
+    INIT_CLASS_ENTRY(ce, "ProtocolBuffers", php_protocolbuffers_methods);
+    protocol_buffers_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
+
+    php_protocol_buffers_invalid_byte_sequence_exception(TSRMLS_C);
+    php_protocol_buffers_invalid_exception(TSRMLS_C);
+    php_protocolbuffers_uninitialized_message_exception(TSRMLS_C);
+    php_protocolbuffers_descriptor_class(TSRMLS_C);
+    php_protocolbuffers_filed_descriptor_class(TSRMLS_C);
+    php_protocol_buffers_serializable(TSRMLS_C);
+    php_protocol_buffers_enum_describable(TSRMLS_C);
+    php_protocolbuffers_message_class(TSRMLS_C);
+    php_protocolbuffers_message_options_class(TSRMLS_C);
+    php_protocolbuffers_enum_class(TSRMLS_C);
+    php_protocolbuffers_enum_descriptor_class(TSRMLS_C);
+    php_protocolbuffers_enum_value_descriptor_class(TSRMLS_C);
+    php_protocolbuffers_enum_descriptor_builder_class(TSRMLS_C);
+    php_protocolbuffers_php_message_options_class(TSRMLS_C);
+    php_protocolbuffers_descriptor_builder_class(TSRMLS_C);
+    php_protocolbuffers_unknown_field_class(TSRMLS_C);
+    php_protocolbuffers_unknown_field_set_class(TSRMLS_C);
+    php_protocolbuffers_helper_class(TSRMLS_C);
+    php_protocolbuffers_extension_registry_class(TSRMLS_C);
 
 #define PB_DECLARE_CONST_STRING(name, value) \
-	zend_declare_class_constant_string(protocol_buffers_class_entry, ZEND_STRS(#name)-1, "php" TSRMLS_CC);
+    zend_declare_class_constant_string(protocol_buffers_class_entry, ZEND_STRS(#name)-1, "php" TSRMLS_CC);
 
 #define PB_DECLARE_CONST_LONG(name, value) \
-	zend_declare_class_constant_long(protocol_buffers_class_entry, ZEND_STRS(#name)-1, value TSRMLS_CC);
-
-	PB_DECLARE_CONST_LONG(WIRETYPE_VARINT,           WIRETYPE_VARINT);
-	PB_DECLARE_CONST_LONG(WIRETYPE_FIXED64,          WIRETYPE_FIXED64);
-	PB_DECLARE_CONST_LONG(WIRETYPE_LENGTH_DELIMITED, WIRETYPE_LENGTH_DELIMITED);
-	PB_DECLARE_CONST_LONG(WIRETYPE_START_GROUP,      WIRETYPE_START_GROUP);
-	PB_DECLARE_CONST_LONG(WIRETYPE_END_GROUP,        WIRETYPE_END_GROUP);
-	PB_DECLARE_CONST_LONG(WIRETYPE_FIXED32,          WIRETYPE_FIXED32);
-
-	PB_DECLARE_CONST_LONG(TYPE_DOUBLE,    TYPE_DOUBLE);
-	PB_DECLARE_CONST_LONG(TYPE_FLOAT,     TYPE_FLOAT);
-	PB_DECLARE_CONST_LONG(TYPE_INT64,     TYPE_INT64);
-	PB_DECLARE_CONST_LONG(TYPE_UINT64,    TYPE_UINT64);
-	PB_DECLARE_CONST_LONG(TYPE_INT32,     TYPE_INT32);
-	PB_DECLARE_CONST_LONG(TYPE_FIXED64,   TYPE_FIXED64);
-	PB_DECLARE_CONST_LONG(TYPE_FIXED32,   TYPE_FIXED32);
-	PB_DECLARE_CONST_LONG(TYPE_BOOL,      TYPE_BOOL);
-	PB_DECLARE_CONST_LONG(TYPE_STRING,    TYPE_STRING);
-	PB_DECLARE_CONST_LONG(TYPE_GROUP,     TYPE_GROUP);
-	PB_DECLARE_CONST_LONG(TYPE_MESSAGE,   TYPE_MESSAGE);
-	PB_DECLARE_CONST_LONG(TYPE_BYTES,     TYPE_BYTES);
-	PB_DECLARE_CONST_LONG(TYPE_UINT32,    TYPE_UINT32);
-	PB_DECLARE_CONST_LONG(TYPE_ENUM,      TYPE_ENUM);
-	PB_DECLARE_CONST_LONG(TYPE_SFIXED32,  TYPE_SFIXED32);
-	PB_DECLARE_CONST_LONG(TYPE_SFIXED64,  TYPE_SFIXED64);
-	PB_DECLARE_CONST_LONG(TYPE_SINT32,    TYPE_SINT32);
-	PB_DECLARE_CONST_LONG(TYPE_SINT64,    TYPE_SINT64);
-	PB_DECLARE_CONST_LONG(MAX_FIELD_TYPE, MAX_FIELD_TYPE);
-
-	PB_DECLARE_CONST_STRING(PHP_MESSAGE_OPTION, "php");
+    zend_declare_class_constant_long(protocol_buffers_class_entry, ZEND_STRS(#name)-1, value TSRMLS_CC);
+
+    PB_DECLARE_CONST_LONG(WIRETYPE_VARINT,           WIRETYPE_VARINT);
+    PB_DECLARE_CONST_LONG(WIRETYPE_FIXED64,          WIRETYPE_FIXED64);
+    PB_DECLARE_CONST_LONG(WIRETYPE_LENGTH_DELIMITED, WIRETYPE_LENGTH_DELIMITED);
+    PB_DECLARE_CONST_LONG(WIRETYPE_START_GROUP,      WIRETYPE_START_GROUP);
+    PB_DECLARE_CONST_LONG(WIRETYPE_END_GROUP,        WIRETYPE_END_GROUP);
+    PB_DECLARE_CONST_LONG(WIRETYPE_FIXED32,          WIRETYPE_FIXED32);
+
+    PB_DECLARE_CONST_LONG(TYPE_DOUBLE,    TYPE_DOUBLE);
+    PB_DECLARE_CONST_LONG(TYPE_FLOAT,     TYPE_FLOAT);
+    PB_DECLARE_CONST_LONG(TYPE_INT64,     TYPE_INT64);
+    PB_DECLARE_CONST_LONG(TYPE_UINT64,    TYPE_UINT64);
+    PB_DECLARE_CONST_LONG(TYPE_INT32,     TYPE_INT32);
+    PB_DECLARE_CONST_LONG(TYPE_FIXED64,   TYPE_FIXED64);
+    PB_DECLARE_CONST_LONG(TYPE_FIXED32,   TYPE_FIXED32);
+    PB_DECLARE_CONST_LONG(TYPE_BOOL,      TYPE_BOOL);
+    PB_DECLARE_CONST_LONG(TYPE_STRING,    TYPE_STRING);
+    PB_DECLARE_CONST_LONG(TYPE_GROUP,     TYPE_GROUP);
+    PB_DECLARE_CONST_LONG(TYPE_MESSAGE,   TYPE_MESSAGE);
+    PB_DECLARE_CONST_LONG(TYPE_BYTES,     TYPE_BYTES);
+    PB_DECLARE_CONST_LONG(TYPE_UINT32,    TYPE_UINT32);
+    PB_DECLARE_CONST_LONG(TYPE_ENUM,      TYPE_ENUM);
+    PB_DECLARE_CONST_LONG(TYPE_SFIXED32,  TYPE_SFIXED32);
+    PB_DECLARE_CONST_LONG(TYPE_SFIXED64,  TYPE_SFIXED64);
+    PB_DECLARE_CONST_LONG(TYPE_SINT32,    TYPE_SINT32);
+    PB_DECLARE_CONST_LONG(TYPE_SINT64,    TYPE_SINT64);
+    PB_DECLARE_CONST_LONG(MAX_FIELD_TYPE, MAX_FIELD_TYPE);
+
+    PB_DECLARE_CONST_STRING(PHP_MESSAGE_OPTION, "php");
 
 #undef PB_DECLARE_CONST_LONG
 
@@ -269,17 +269,17 @@ static void php_protocolbuffers_init(TSRMLS_D)
 
 PHP_MINFO_FUNCTION(protocolbuffers)
 {
-	php_printf("PHP Protocol Buffers Extension\n");
+    php_printf("PHP Protocol Buffers Extension\n");
 
-	php_info_print_table_start();
-	php_info_print_table_header(2, "Protocol Buffers Support", "enabled");
-	php_info_print_table_row(2, "Version", PHP_PROTOCOLBUFFERS_VERSION);
-	php_info_print_table_end();
+    php_info_print_table_start();
+    php_info_print_table_header(2, "Protocol Buffers Support", "enabled");
+    php_info_print_table_row(2, "Version", PHP_PROTOCOLBUFFERS_VERSION);
+    php_info_print_table_end();
 }
 
 PHP_INI_BEGIN()
-	STD_PHP_INI_BOOLEAN("protocolbuffers.strict_mode", "1", PHP_INI_ALL, OnUpdateLong, strict_mode, zend_protocolbuffers_globals, protocolbuffers_globals)
-	STD_PHP_INI_BOOLEAN("protocolbuffers.validate_string", "1", PHP_INI_ALL, OnUpdateLong, validate_string, zend_protocolbuffers_globals, protocolbuffers_globals)
+    STD_PHP_INI_BOOLEAN("protocolbuffers.strict_mode", "1", PHP_INI_ALL, OnUpdateLong, strict_mode, zend_protocolbuffers_globals, protocolbuffers_globals)
+    STD_PHP_INI_BOOLEAN("protocolbuffers.validate_string", "1", PHP_INI_ALL, OnUpdateLong, validate_string, zend_protocolbuffers_globals, protocolbuffers_globals)
 PHP_INI_END()
 
 static PHP_GINIT_FUNCTION(protocolbuffers)
@@ -292,139 +292,139 @@ static PHP_GSHUTDOWN_FUNCTION(protocolbuffers)
 
 PHP_MINIT_FUNCTION(protocolbuffers)
 {
-	REGISTER_INI_ENTRIES();
+    REGISTER_INI_ENTRIES();
 
-	php_protocolbuffers_init(TSRMLS_C);
-	return SUCCESS;
+    php_protocolbuffers_init(TSRMLS_C);
+    return SUCCESS;
 }
 
 static int implemented = 0;
 PHP_RINIT_FUNCTION(protocolbuffers)
 {
-	zend_class_entry **json;
-	PBG(messages) = NULL;
-	PBG(classes) = NULL;
-	PBG(extension_registry) = NULL;
-	PBG(strict_mode) = 1;
-
-	// NOTE(chobie): prevent segmentaiton fault on CentOS box (CentOS uses json shared modules.)
-	if (implemented == 0 && zend_lookup_class("JsonSerializable", sizeof("JsonSerializable")-1, &json TSRMLS_CC) != FAILURE) {
-		zend_class_implements(php_protocol_buffers_message_class_entry TSRMLS_CC, 1, *json);
-		implemented = 1;
-	}
-
-	if (!PBG(messages)) {
-		ALLOC_HASHTABLE(PBG(messages));
-		zend_hash_init(PBG(messages), 0, NULL, NULL, 0);
-	}
-
-	if (!PBG(classes)) {
-		ALLOC_HASHTABLE(PBG(classes));
-		zend_hash_init(PBG(classes), 0, NULL, NULL, 0);
-	}
-	PBG(validate_string) = 1;
-
-	return SUCCESS;
+    zend_class_entry **json;
+    PBG(messages) = NULL;
+    PBG(classes) = NULL;
+    PBG(extension_registry) = NULL;
+    PBG(strict_mode) = 1;
+
+    // NOTE(chobie): prevent segmentaiton fault on CentOS box (CentOS uses json shared modules.)
+    if (implemented == 0 && zend_lookup_class("JsonSerializable", sizeof("JsonSerializable")-1, &json TSRMLS_CC) != FAILURE) {
+        zend_class_implements(php_protocol_buffers_message_class_entry TSRMLS_CC, 1, *json);
+        implemented = 1;
+    }
+
+    if (!PBG(messages)) {
+        ALLOC_HASHTABLE(PBG(messages));
+        zend_hash_init(PBG(messages), 0, NULL, NULL, 0);
+    }
+
+    if (!PBG(classes)) {
+        ALLOC_HASHTABLE(PBG(classes));
+        zend_hash_init(PBG(classes), 0, NULL, NULL, 0);
+    }
+    PBG(validate_string) = 1;
+
+    return SUCCESS;
 }
 
 
 PHP_MSHUTDOWN_FUNCTION(protocolbuffers)
 {
-	UNREGISTER_INI_ENTRIES();
-	return SUCCESS;
+    UNREGISTER_INI_ENTRIES();
+    return SUCCESS;
 }
 
 PHP_RSHUTDOWN_FUNCTION(protocolbuffers)
 {
-		if (PBG(messages)) {
-			zend_try {
-			int i = 0;
-			HashPosition pos;
-			php_protocolbuffers_scheme_container **element;
-
-			for(zend_hash_internal_pointer_reset_ex(PBG(messages), &pos);
-							zend_hash_get_current_data_ex(PBG(messages), (void **)&element, &pos) == SUCCESS;
-							zend_hash_move_forward_ex(PBG(messages), &pos)
-			) {
-				for (i = 0; i < (*element)->size; i++) {
-					if ((*element)->scheme[i].original_name != NULL) {
-						efree((*element)->scheme[i].original_name);
-					}
-					if ((*element)->scheme[i].name != NULL) {
-						efree((*element)->scheme[i].name);
-					}
-					if ((*element)->scheme[i].mangled_name != NULL) {
-						efree((*element)->scheme[i].mangled_name);
-					}
-					if ((*element)->scheme[i].default_value != NULL) {
-						zval_ptr_dtor(&((*element)->scheme[i].default_value));
-					}
-				}
-
-				if ((*element)->single_property_name != NULL) {
-					efree((*element)->single_property_name);
-				}
-
-				if ((*element)->orig_single_property_name != NULL &&
-					memcmp((*element)->orig_single_property_name, php_protocolbuffers_get_default_single_property_name(), php_protocolbuffers_get_default_single_property_name_len()) != 0) {
-					efree((*element)->orig_single_property_name);
-				}
-
-				if ((*element)->scheme != NULL) {
-					efree((*element)->scheme);
-				}
-
-				if ((*element)->extensions != NULL) {
-					efree((*element)->extensions);
-				}
-
-				efree(*element);
-			}
-
-			zend_hash_destroy(PBG(messages));
-			FREE_HASHTABLE(PBG(messages));
-			PBG(messages) = NULL;
-		}
-		zend_end_try();
-	}
-
-	if (PBG(classes)) {
-		zend_try {
-			zend_hash_destroy(PBG(classes));
-			FREE_HASHTABLE(PBG(classes));
-			PBG(classes) = NULL;
-		}
-		zend_end_try();
-	}
-
-	if (PBG(extension_registry)) {
-		zval_ptr_dtor(&PBG(extension_registry));
-	}
-
-
-	return SUCCESS;
+        if (PBG(messages)) {
+            zend_try {
+            int i = 0;
+            HashPosition pos;
+            php_protocolbuffers_scheme_container **element;
+
+            for(zend_hash_internal_pointer_reset_ex(PBG(messages), &pos);
+                            zend_hash_get_current_data_ex(PBG(messages), (void **)&element, &pos) == SUCCESS;
+                            zend_hash_move_forward_ex(PBG(messages), &pos)
+            ) {
+                for (i = 0; i < (*element)->size; i++) {
+                    if ((*element)->scheme[i].original_name != NULL) {
+                        efree((*element)->scheme[i].original_name);
+                    }
+                    if ((*element)->scheme[i].name != NULL) {
+                        efree((*element)->scheme[i].name);
+                    }
+                    if ((*element)->scheme[i].mangled_name != NULL) {
+                        efree((*element)->scheme[i].mangled_name);
+                    }
+                    if ((*element)->scheme[i].default_value != NULL) {
+                        zval_ptr_dtor(&((*element)->scheme[i].default_value));
+                    }
+                }
+
+                if ((*element)->single_property_name != NULL) {
+                    efree((*element)->single_property_name);
+                }
+
+                if ((*element)->orig_single_property_name != NULL &&
+                    memcmp((*element)->orig_single_property_name, php_protocolbuffers_get_default_single_property_name(), php_protocolbuffers_get_default_single_property_name_len()) != 0) {
+                    efree((*element)->orig_single_property_name);
+                }
+
+                if ((*element)->scheme != NULL) {
+                    efree((*element)->scheme);
+                }
+
+                if ((*element)->extensions != NULL) {
+                    efree((*element)->extensions);
+                }
+
+                efree(*element);
+            }
+
+            zend_hash_destroy(PBG(messages));
+            FREE_HASHTABLE(PBG(messages));
+            PBG(messages) = NULL;
+        }
+        zend_end_try();
+    }
+
+    if (PBG(classes)) {
+        zend_try {
+            zend_hash_destroy(PBG(classes));
+            FREE_HASHTABLE(PBG(classes));
+            PBG(classes) = NULL;
+        }
+        zend_end_try();
+    }
+
+    if (PBG(extension_registry)) {
+        zval_ptr_dtor(&PBG(extension_registry));
+    }
+
+
+    return SUCCESS;
 }
 
 
 zend_module_entry protocolbuffers_module_entry = {
 #if ZEND_MODULE_API_NO >= 20010901
-	STANDARD_MODULE_HEADER,
+    STANDARD_MODULE_HEADER,
 #endif
-	"protocolbuffers",
-	NULL,					/* Functions */
-	PHP_MINIT(protocolbuffers),	/* MINIT */
-	PHP_MSHUTDOWN(protocolbuffers),	/* MSHUTDOWN */
-	PHP_RINIT(protocolbuffers),	/* RINIT */
-	PHP_RSHUTDOWN(protocolbuffers),		/* RSHUTDOWN */
-	PHP_MINFO(protocolbuffers),	/* MINFO */
+    "protocolbuffers",
+    NULL,                    /* Functions */
+    PHP_MINIT(protocolbuffers),    /* MINIT */
+    PHP_MSHUTDOWN(protocolbuffers),    /* MSHUTDOWN */
+    PHP_RINIT(protocolbuffers),    /* RINIT */
+    PHP_RSHUTDOWN(protocolbuffers),        /* RSHUTDOWN */
+    PHP_MINFO(protocolbuffers),    /* MINFO */
 #if ZEND_MODULE_API_NO >= 20010901
-	PHP_PROTOCOLBUFFERS_VERSION,
+    PHP_PROTOCOLBUFFERS_VERSION,
 #endif
-	PHP_MODULE_GLOBALS(protocolbuffers),
-	PHP_GINIT(protocolbuffers),
-	PHP_GSHUTDOWN(protocolbuffers),
-	NULL,
-	STANDARD_MODULE_PROPERTIES_EX
+    PHP_MODULE_GLOBALS(protocolbuffers),
+    PHP_GINIT(protocolbuffers),
+    PHP_GSHUTDOWN(protocolbuffers),
+    NULL,
+    STANDARD_MODULE_PROPERTIES_EX
 };
 
 
diff --git a/protocolbuffers.h b/protocolbuffers.h
index 0a73e66..f7df0a5 100644
--- a/protocolbuffers.h
+++ b/protocolbuffers.h
@@ -85,7 +85,7 @@
 #else
 /* NOTE: zend_register_ns_class_alias had TSRMLS bug under 5.4. we have to define it for compatibility */
 #define PHP_PROTOCOLBUFFERS_REGISTER_NS_CLASS_ALIAS(ns, name, ce) \
-	zend_register_class_alias_ex(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, ce TSRMLS_CC)
+    zend_register_class_alias_ex(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, ce TSRMLS_CC)
 #endif
 
 #if PHP_VERSION_ID < 50300
@@ -144,179 +144,179 @@ static const int64_t kLongMax = LONG_MAX;
 #endif
 
 #define php_protocolbuffers_raise_error_or_exception(ce, warning_level, use_exception, ...) \
-	do {\
-		if (use_exception) { \
-			zend_throw_exception_ex(ce, 0 TSRMLS_CC, __VA_ARGS__); \
-		} else { \
-			php_error_docref(NULL TSRMLS_CC, warning_level, __VA_ARGS__); \
-		} \
-	} while(0);
+    do {\
+        if (use_exception) { \
+            zend_throw_exception_ex(ce, 0 TSRMLS_CC, __VA_ARGS__); \
+        } else { \
+            php_error_docref(NULL TSRMLS_CC, warning_level, __VA_ARGS__); \
+        } \
+    } while(0);
 
 zend_class_entry *php_protocolbuffers_get_exception_base(TSRMLS_D);
 
 typedef struct php_protocolbuffers_scheme
 {
-	int tag;
-	char *name;
-	int name_len;
-	ulong name_h;
-	char *original_name;
-	int original_name_len;
-	char *mangled_name;
-	int mangled_name_len;
-	ulong mangled_name_h;
-	int magic_type;
-	/* TODO: use flags */
-	int type;
-	int flags;
-	int required;
-	int optional;
-	int scheme_type;
-	int repeated;
-	int packed;
-	int skip;
-	int is_extension;
-	char *message;
-	char *enum_msg;
-	zval *default_value;
-	zend_class_entry *ce;
+    int tag;
+    char *name;
+    int name_len;
+    ulong name_h;
+    char *original_name;
+    int original_name_len;
+    char *mangled_name;
+    int mangled_name_len;
+    ulong mangled_name_h;
+    int magic_type;
+    /* TODO: use flags */
+    int type;
+    int flags;
+    int required;
+    int optional;
+    int scheme_type;
+    int repeated;
+    int packed;
+    int skip;
+    int is_extension;
+    char *message;
+    char *enum_msg;
+    zval *default_value;
+    zend_class_entry *ce;
 } php_protocolbuffers_scheme;
 
 typedef struct {
-	int begin;
-	int end;
+    int begin;
+    int end;
 } php_protocolbuffers_extension_range;
 
 typedef struct {
-	char *name;
-	int name_len;
-	char *filename;
-	int filename_len;
-	int is_extendable;
-	php_protocolbuffers_scheme *scheme;
-	int use_single_property;
-	char *orig_single_property_name;
-	int orig_single_property_name_len;
-	char *single_property_name;
-	int single_property_name_len;
-	ulong single_property_h;
-	int size;
-	int process_unknown_fields;
-	int use_wakeup_and_sleep;
-	int extension_cnt;
-	php_protocolbuffers_extension_range *extensions;
+    char *name;
+    int name_len;
+    char *filename;
+    int filename_len;
+    int is_extendable;
+    php_protocolbuffers_scheme *scheme;
+    int use_single_property;
+    char *orig_single_property_name;
+    int orig_single_property_name_len;
+    char *single_property_name;
+    int single_property_name_len;
+    ulong single_property_h;
+    int size;
+    int process_unknown_fields;
+    int use_wakeup_and_sleep;
+    int extension_cnt;
+    php_protocolbuffers_extension_range *extensions;
 } php_protocolbuffers_scheme_container;
 
 
 enum WireType {
-	WIRETYPE_VARINT           = 0,
-	WIRETYPE_FIXED64          = 1,
-	WIRETYPE_LENGTH_DELIMITED = 2,
-	WIRETYPE_START_GROUP      = 3,
-	WIRETYPE_END_GROUP        = 4,
-	WIRETYPE_FIXED32          = 5,
+    WIRETYPE_VARINT           = 0,
+    WIRETYPE_FIXED64          = 1,
+    WIRETYPE_LENGTH_DELIMITED = 2,
+    WIRETYPE_START_GROUP      = 3,
+    WIRETYPE_END_GROUP        = 4,
+    WIRETYPE_FIXED32          = 5,
 };
 
 // Lite alternative to FieldDescriptor::Type.  Must be kept in sync.
 enum FieldType {
-	TYPE_DOUBLE         = 1,
-	TYPE_FLOAT          = 2,
-	TYPE_INT64          = 3,
-	TYPE_UINT64         = 4,
-	TYPE_INT32          = 5,
-	TYPE_FIXED64        = 6,
-	TYPE_FIXED32        = 7,
-	TYPE_BOOL           = 8,
-	TYPE_STRING         = 9,
-	TYPE_GROUP          = 10,
-	TYPE_MESSAGE        = 11,
-	TYPE_BYTES          = 12,
-	TYPE_UINT32         = 13,
-	TYPE_ENUM           = 14,
-	TYPE_SFIXED32       = 15,
-	TYPE_SFIXED64       = 16,
-	TYPE_SINT32         = 17,
-	TYPE_SINT64         = 18,
-	MAX_FIELD_TYPE      = 18,
+    TYPE_DOUBLE         = 1,
+    TYPE_FLOAT          = 2,
+    TYPE_INT64          = 3,
+    TYPE_UINT64         = 4,
+    TYPE_INT32          = 5,
+    TYPE_FIXED64        = 6,
+    TYPE_FIXED32        = 7,
+    TYPE_BOOL           = 8,
+    TYPE_STRING         = 9,
+    TYPE_GROUP          = 10,
+    TYPE_MESSAGE        = 11,
+    TYPE_BYTES          = 12,
+    TYPE_UINT32         = 13,
+    TYPE_ENUM           = 14,
+    TYPE_SFIXED32       = 15,
+    TYPE_SFIXED64       = 16,
+    TYPE_SINT32         = 17,
+    TYPE_SINT64         = 18,
+    MAX_FIELD_TYPE      = 18,
 };
 
 typedef struct php_protocolbuffers_serializer
 {
-	uint8_t *buffer;
-	size_t buffer_size;
-	size_t buffer_capacity;
-	size_t buffer_offset;
+    uint8_t *buffer;
+    size_t buffer_size;
+    size_t buffer_capacity;
+    size_t buffer_offset;
 } php_protocolbuffers_serializer;
 
 typedef struct{
-	zend_object zo;
-	char *name;
-	size_t name_len;
-	int free_container;
-	php_protocolbuffers_scheme_container *container;
+    zend_object zo;
+    char *name;
+    size_t name_len;
+    int free_container;
+    php_protocolbuffers_scheme_container *container;
 } php_protocolbuffers_descriptor;
 
 typedef struct{
-	zend_object zo;
-	zval *container;
-	int max;
-	int offset;
+    zend_object zo;
+    zval *container;
+    int max;
+    int offset;
 } php_protocolbuffers_message;
 
 typedef struct{
-	zend_object zo;
-	int max;
-	int offset;
+    zend_object zo;
+    int max;
+    int offset;
 } php_protocolbuffers_unknown_field_set;
 
 typedef struct{
-	zend_object zo;
-	HashTable *registry;
+    zend_object zo;
+    HashTable *registry;
 } php_protocolbuffers_extension_registry;
 
 typedef union {
-	uint64_t varint;
-	struct {
-		uint8_t *val;
-		size_t len;
-	} buffer;
+    uint64_t varint;
+    struct {
+        uint8_t *val;
+        size_t len;
+    } buffer;
 } unknown_value;
 
 typedef struct{
-	zend_object zo;
-	int number;
-	int type;
-	HashTable *ht;
+    zend_object zo;
+    int number;
+    int type;
+    HashTable *ht;
 } php_protocolbuffers_unknown_field;
 
 
 #  if ZEND_MODULE_API_NO >= 20100525
 #  define PHP_PROTOCOLBUFFERS_STD_CREATE_OBJECT(STRUCT_NAME) \
-	STRUCT_NAME *object;\
-	\
-	object = (STRUCT_NAME*)ecalloc(1, sizeof(*object));\
-	zend_object_std_init(&object->zo, ce TSRMLS_CC);\
-	object_properties_init(&object->zo, ce);\
-	\
-	retval.handle = zend_objects_store_put(object,\
-		(zend_objects_store_dtor_t)zend_objects_destroy_object,\
-		(zend_objects_free_object_storage_t) STRUCT_NAME##_free_storage ,\
-	NULL TSRMLS_CC);\
-	retval.handlers = zend_get_std_object_handlers();
+    STRUCT_NAME *object;\
+    \
+    object = (STRUCT_NAME*)ecalloc(1, sizeof(*object));\
+    zend_object_std_init(&object->zo, ce TSRMLS_CC);\
+    object_properties_init(&object->zo, ce);\
+    \
+    retval.handle = zend_objects_store_put(object,\
+        (zend_objects_store_dtor_t)zend_objects_destroy_object,\
+        (zend_objects_free_object_storage_t) STRUCT_NAME##_free_storage ,\
+    NULL TSRMLS_CC);\
+    retval.handlers = zend_get_std_object_handlers();
 #  else
 #  define PHP_PROTOCOLBUFFERS_STD_CREATE_OBJECT(STRUCT_NAME) \
-	STRUCT_NAME *object;\
-	zval *tmp = NULL;\
-	\
-	object = (STRUCT_NAME*)ecalloc(1, sizeof(*object));\
-	zend_object_std_init(&object->zo, ce TSRMLS_CC);\
-	zend_hash_copy(object->zo.properties, &ce->default_properties, (copy_ctor_func_t)zval_add_ref, (void *)&tmp, sizeof(zval *)); \
-	\
-	retval.handle = zend_objects_store_put(object,\
-		(zend_objects_store_dtor_t)zend_objects_destroy_object,\
-		(zend_objects_free_object_storage_t) STRUCT_NAME##_free_storage ,\
-	NULL TSRMLS_CC);\
-	retval.handlers = zend_get_std_object_handlers();
+    STRUCT_NAME *object;\
+    zval *tmp = NULL;\
+    \
+    object = (STRUCT_NAME*)ecalloc(1, sizeof(*object));\
+    zend_object_std_init(&object->zo, ce TSRMLS_CC);\
+    zend_hash_copy(object->zo.properties, &ce->default_properties, (copy_ctor_func_t)zval_add_ref, (void *)&tmp, sizeof(zval *)); \
+    \
+    retval.handle = zend_objects_store_put(object,\
+        (zend_objects_store_dtor_t)zend_objects_destroy_object,\
+        (zend_objects_free_object_storage_t) STRUCT_NAME##_free_storage ,\
+    NULL TSRMLS_CC);\
+    retval.handlers = zend_get_std_object_handlers();
 #  endif
 
 #define PHP_PROTOCOLBUFFERS_GET_OBJECT(STRUCT_NAME, OBJECT) (STRUCT_NAME *)zend_object_store_get_object(OBJECT TSRMLS_CC);
@@ -340,4 +340,4 @@ typedef struct{
 
 #include "core.h"
 
-#endif
\ No newline at end of file
+#endif