aboutsummaryrefslogtreecommitdiff
path: root/php
diff options
context:
space:
mode:
Diffstat (limited to 'php')
-rw-r--r--php/README.md6
-rw-r--r--php/ext/google/protobuf/array.c12
-rw-r--r--php/ext/google/protobuf/def.c3
-rw-r--r--php/ext/google/protobuf/encode_decode.c68
-rw-r--r--php/ext/google/protobuf/map.c30
-rw-r--r--php/ext/google/protobuf/message.c5
-rw-r--r--php/ext/google/protobuf/package.xml17
-rw-r--r--php/ext/google/protobuf/protobuf.c12
-rw-r--r--php/ext/google/protobuf/protobuf.h26
-rw-r--r--php/ext/google/protobuf/storage.c31
-rw-r--r--php/ext/google/protobuf/type_check.c1
-rw-r--r--php/ext/google/protobuf/utf8.c2
-rw-r--r--php/src/Google/Protobuf/Internal/Message.php45
-rw-r--r--php/tests/array_test.php40
-rw-r--r--php/tests/test.pb.php1385
-rwxr-xr-xphp/tests/test.sh5
-rw-r--r--php/tests/test_include.pb.php36
-rw-r--r--php/tests/test_util.php4
18 files changed, 1586 insertions, 142 deletions
diff --git a/php/README.md b/php/README.md
index 2f5380f5..ec92d329 100644
--- a/php/README.md
+++ b/php/README.md
@@ -16,7 +16,8 @@ generation functionality.
To use PHP runtime library requires:
-- PHP 5.5 or above.
+- C extension: PHP 5.5.x or 5.6.x.
+- PHP package: PHP 5.5, 5.6 or 7.
## Installation
@@ -94,6 +95,5 @@ Known Issues
* Map fields may not be garbage-collected if there is cycle reference.
* No debug information for messages in c extension.
* HHVM not tested.
-* PHP 7.0 not tested.
-* C extension not tested on windows.
+* C extension not tested on windows, mac, php 7.0.
* Message name cannot be Empty.
diff --git a/php/ext/google/protobuf/array.c b/php/ext/google/protobuf/array.c
index fde4f726..215dcd46 100644
--- a/php/ext/google/protobuf/array.c
+++ b/php/ext/google/protobuf/array.c
@@ -160,7 +160,7 @@ static void repeated_field_write_dimension(zval *object, zval *offset,
unsigned char memory[NATIVE_SLOT_MAX_SIZE];
memset(memory, 0, NATIVE_SLOT_MAX_SIZE);
- if (!native_slot_set(intern->type, intern->msg_ce, memory, value)) {
+ if (!native_slot_set(intern->type, intern->msg_ce, memory, value TSRMLS_CC)) {
return;
}
@@ -169,7 +169,7 @@ static void repeated_field_write_dimension(zval *object, zval *offset,
} else {
if (protobuf_convert_to_uint64(offset, &index)) {
if (!zend_hash_index_exists(ht, index)) {
- zend_error(E_USER_ERROR, "Element at %d doesn't exist.\n", index);
+ zend_error(E_USER_ERROR, "Element at %llu doesn't exist.\n", index);
return;
}
} else {
@@ -192,7 +192,7 @@ static HashTable *repeated_field_get_gc(zval *object, zval ***table,
// C RepeatedField Utilities
// -----------------------------------------------------------------------------
-void *repeated_field_index_native(RepeatedField *intern, int index) {
+void *repeated_field_index_native(RepeatedField *intern, int index TSRMLS_DC) {
HashTable *ht = HASH_OF(intern->array);
void *value;
@@ -222,7 +222,7 @@ void repeated_field_create_with_type(zend_class_entry *ce,
zend_object_store_get_object(*repeated_field TSRMLS_CC);
intern->type = upb_fielddef_type(field);
if (intern->type == UPB_TYPE_MESSAGE) {
- upb_msgdef *msg = upb_fielddef_msgsubdef(field);
+ const upb_msgdef *msg = upb_fielddef_msgsubdef(field);
zval *desc_php = get_def_obj(msg);
Descriptor *desc = zend_object_store_get_object(desc_php TSRMLS_CC);
intern->msg_ce = desc->klass;
@@ -321,7 +321,7 @@ PHP_METHOD(RepeatedField, offsetGet) {
HashTable *table = HASH_OF(intern->array);
if (zend_hash_index_find(table, index, (void **)&memory) == FAILURE) {
- zend_error(E_USER_ERROR, "Element at %d doesn't exist.\n", index);
+ zend_error(E_USER_ERROR, "Element at %ld doesn't exist.\n", index);
return;
}
@@ -365,7 +365,7 @@ PHP_METHOD(RepeatedField, offsetUnset) {
// Only the element at the end of the array can be removed.
if (index == -1 ||
index != (zend_hash_num_elements(HASH_OF(intern->array)) - 1)) {
- zend_error(E_USER_ERROR, "Cannot remove element at %d.\n", index);
+ zend_error(E_USER_ERROR, "Cannot remove element at %ld.\n", index);
return;
}
diff --git a/php/ext/google/protobuf/def.c b/php/ext/google/protobuf/def.c
index cbd0ec62..156eca07 100644
--- a/php/ext/google/protobuf/def.c
+++ b/php/ext/google/protobuf/def.c
@@ -318,7 +318,8 @@ PHP_METHOD(DescriptorPool, internalAddGeneratedFile) {
add_def_obj(desc->def_type_lower, desc_php); \
/* Unlike other messages, MapEntry is shared by all map fields and doesn't \
* have generated PHP class.*/ \
- if (upb_def_type(def) == UPB_DEF_MSG && upb_msgdef_mapentry(def)) { \
+ if (upb_def_type(def) == UPB_DEF_MSG && \
+ upb_msgdef_mapentry(upb_downcast_msgdef(def))) { \
break; \
} \
/* Prepend '.' to package name to make it absolute. */ \
diff --git a/php/ext/google/protobuf/encode_decode.c b/php/ext/google/protobuf/encode_decode.c
index 4b51dabe..eafe1ae8 100644
--- a/php/ext/google/protobuf/encode_decode.c
+++ b/php/ext/google/protobuf/encode_decode.c
@@ -29,6 +29,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "protobuf.h"
+#include "utf8.h"
/* stringsink *****************************************************************/
@@ -201,9 +202,10 @@ static void *startseq_handler(void* closure, const void* hd) {
static bool append##type##_handler(void* closure, const void* hd, \
ctype val) { \
zval* array = (zval*)closure; \
+ TSRMLS_FETCH(); \
RepeatedField* intern = \
(RepeatedField*)zend_object_store_get_object(array TSRMLS_CC); \
- repeated_field_push_native(intern, &val); \
+ repeated_field_push_native(intern, &val TSRMLS_CC); \
return true; \
}
@@ -220,6 +222,7 @@ static void* appendstr_handler(void *closure,
const void *hd,
size_t size_hint) {
zval* array = (zval*)closure;
+ TSRMLS_FETCH();
RepeatedField* intern =
(RepeatedField*)zend_object_store_get_object(array TSRMLS_CC);
@@ -236,6 +239,7 @@ static void* appendbytes_handler(void *closure,
const void *hd,
size_t size_hint) {
zval* array = (zval*)closure;
+ TSRMLS_FETCH();
RepeatedField* intern =
(RepeatedField*)zend_object_store_get_object(array TSRMLS_CC);
@@ -298,6 +302,7 @@ static size_t stringdata_handler(void* closure, const void* hd,
// Appends a submessage to a repeated field.
static void *appendsubmsg_handler(void *closure, const void *hd) {
zval* array = (zval*)closure;
+ TSRMLS_FETCH();
RepeatedField* intern =
(RepeatedField*)zend_object_store_get_object(array TSRMLS_CC);
@@ -323,6 +328,7 @@ static void *submsg_handler(void *closure, const void *hd) {
MessageHeader* msg = closure;
const submsg_handlerdata_t* submsgdata = hd;
zval* subdesc_php = get_def_obj((void*)submsgdata->md);
+ TSRMLS_FETCH();
Descriptor* subdesc = zend_object_store_get_object(subdesc_php TSRMLS_CC);
zend_class_entry* subklass = subdesc->klass;
zval* submsg_php;
@@ -411,7 +417,8 @@ static void map_slot_uninit(void* memory, upb_fieldtype_t type) {
}
}
-static void map_slot_key(upb_fieldtype_t type, const void* from, char** keyval,
+static void map_slot_key(upb_fieldtype_t type, const void* from,
+ const char** keyval,
size_t* length) {
if (type == UPB_TYPE_STRING) {
zval* key_php = **(zval***)from;
@@ -423,7 +430,8 @@ static void map_slot_key(upb_fieldtype_t type, const void* from, char** keyval,
}
}
-static void map_slot_value(upb_fieldtype_t type, const void* from, upb_value* v) {
+static void map_slot_value(upb_fieldtype_t type, const void* from,
+ upb_value* v) {
size_t len;
void* to = upb_value_memory(v);
#ifndef NDEBUG
@@ -464,10 +472,11 @@ static void *startmapentry_handler(void *closure, const void *hd) {
// Handler to end a map entry: inserts the value defined during the message into
// the map. This is the 'endmsg' handler on the map entry msgdef.
-static bool endmap_handler(void *closure, const void *hd, upb_status* s) {
+static bool endmap_handler(void* closure, const void* hd, upb_status* s) {
map_parse_frame_t* frame = closure;
const map_handlerdata_t* mapdata = hd;
+ TSRMLS_FETCH();
Map *map = (Map *)zend_object_store_get_object(frame->map TSRMLS_CC);
const char* keyval = NULL;
@@ -573,12 +582,12 @@ static void *oneofbytes_handler(void *closure,
}
// Handler for a submessage field in a oneof.
-static void *oneofsubmsg_handler(void *closure,
- const void *hd) {
+static void* oneofsubmsg_handler(void* closure, const void* hd) {
MessageHeader* msg = closure;
const oneof_handlerdata_t *oneofdata = hd;
uint32_t oldcase = DEREF(msg, oneofdata->case_ofs, uint32_t);
zval* subdesc_php = get_def_obj((void*)oneofdata->md);
+ TSRMLS_FETCH();
Descriptor* subdesc = zend_object_store_get_object(subdesc_php TSRMLS_CC);
zend_class_entry* subklass = subdesc->klass;
zval* submsg_php;
@@ -771,8 +780,10 @@ static void add_handlers_for_oneof_field(upb_handlers *h,
upb_handlerattr_uninit(&attr);
}
-static void add_handlers_for_message(const void *closure, upb_handlers *h) {
+static void add_handlers_for_message(const void* closure,
+ upb_handlers* h) {
const upb_msgdef* msgdef = upb_handlers_msgdef(h);
+ TSRMLS_FETCH();
Descriptor* desc = (Descriptor*)zend_object_store_get_object(
get_def_obj((void*)msgdef) TSRMLS_CC);
upb_msg_field_iter i;
@@ -860,7 +871,7 @@ static const upb_pbdecodermethod *msgdef_decodermethod(Descriptor* desc) {
// -----------------------------------------------------------------------------
static void putmsg(zval* msg, const Descriptor* desc, upb_sink* sink,
- int depth);
+ int depth TSRMLS_DC);
static void putstr(zval* str, const upb_fielddef* f, upb_sink* sink);
@@ -868,11 +879,12 @@ static void putrawstr(const char* str, int len, const upb_fielddef* f,
upb_sink* sink);
static void putsubmsg(zval* submsg, const upb_fielddef* f, upb_sink* sink,
- int depth);
+ int depth TSRMLS_DC);
static void putarray(zval* array, const upb_fielddef* f, upb_sink* sink,
- int depth);
-static void putmap(zval* map, const upb_fielddef* f, upb_sink* sink, int depth);
+ int depth TSRMLS_DC);
+static void putmap(zval* map, const upb_fielddef* f, upb_sink* sink, int depth
+ TSRMLS_DC);
static upb_selector_t getsel(const upb_fielddef* f, upb_handlertype_t type) {
upb_selector_t ret;
@@ -881,8 +893,8 @@ static upb_selector_t getsel(const upb_fielddef* f, upb_handlertype_t type) {
return ret;
}
-static void put_optional_value(void* memory, int len, const upb_fielddef* f,
- int depth, upb_sink* sink) {
+static void put_optional_value(const void* memory, int len, const upb_fielddef* f,
+ int depth, upb_sink* sink TSRMLS_DC) {
assert(upb_fielddef_label(f) == UPB_LABEL_OPTIONAL);
switch (upb_fielddef_type(f)) {
@@ -911,7 +923,7 @@ static void put_optional_value(void* memory, int len, const upb_fielddef* f,
break;
case UPB_TYPE_MESSAGE: {
zval* submsg = *(zval**)memory;
- putsubmsg(submsg, f, sink, depth);
+ putsubmsg(submsg, f, sink, depth TSRMLS_CC);
break;
}
default:
@@ -943,7 +955,7 @@ static int raw_value_len(void* memory, int len, const upb_fielddef* f) {
}
static void putmap(zval* map, const upb_fielddef* f, upb_sink* sink,
- int depth) {
+ int depth TSRMLS_DC) {
Map* self;
upb_sink subsink;
const upb_fielddef* key_field;
@@ -960,7 +972,7 @@ static void putmap(zval* map, const upb_fielddef* f, upb_sink* sink,
key_field = map_field_key(f);
value_field = map_field_value(f);
- for (map_begin(map, &it); !map_done(&it); map_next(&it)) {
+ for (map_begin(map, &it TSRMLS_CC); !map_done(&it); map_next(&it)) {
upb_status status;
upb_sink entry_sink;
@@ -970,13 +982,13 @@ static void putmap(zval* map, const upb_fielddef* f, upb_sink* sink,
// Serialize key.
const char *key = map_iter_key(&it, &len);
- put_optional_value(key, len, key_field, depth + 1, &entry_sink);
+ put_optional_value(key, len, key_field, depth + 1, &entry_sink TSRMLS_CC);
// Serialize value.
upb_value value = map_iter_value(&it, &len);
put_optional_value(raw_value(upb_value_memory(&value), value_field),
raw_value_len(upb_value_memory(&value), len, value_field),
- value_field, depth + 1, &entry_sink);
+ value_field, depth + 1, &entry_sink TSRMLS_CC);
upb_sink_endmsg(&entry_sink, &status);
upb_sink_endsubmsg(&subsink, getsel(f, UPB_HANDLER_ENDSUBMSG));
@@ -986,7 +998,7 @@ static void putmap(zval* map, const upb_fielddef* f, upb_sink* sink,
}
static void putmsg(zval* msg_php, const Descriptor* desc, upb_sink* sink,
- int depth) {
+ int depth TSRMLS_DC) {
upb_msg_field_iter i;
upb_status status;
@@ -1023,12 +1035,12 @@ static void putmsg(zval* msg_php, const Descriptor* desc, upb_sink* sink,
if (is_map_field(f)) {
zval* map = *DEREF(msg, offset, zval**);
if (map != NULL) {
- putmap(map, f, sink, depth);
+ putmap(map, f, sink, depth TSRMLS_CC);
}
} else if (upb_fielddef_isseq(f)) {
zval* array = *DEREF(msg, offset, zval**);
if (array != NULL) {
- putarray(array, f, sink, depth);
+ putarray(array, f, sink, depth TSRMLS_CC);
}
} else if (upb_fielddef_isstring(f)) {
zval* str = *DEREF(msg, offset, zval**);
@@ -1036,7 +1048,7 @@ static void putmsg(zval* msg_php, const Descriptor* desc, upb_sink* sink,
putstr(str, f, sink);
}
} else if (upb_fielddef_issubmsg(f)) {
- putsubmsg(*DEREF(msg, offset, zval**), f, sink, depth);
+ putsubmsg(*DEREF(msg, offset, zval**), f, sink, depth TSRMLS_CC);
} else {
upb_selector_t sel = getsel(f, upb_handlers_getprimitivehandlertype(f));
@@ -1113,7 +1125,7 @@ static void putrawstr(const char* str, int len, const upb_fielddef* f,
}
static void putsubmsg(zval* submsg, const upb_fielddef* f, upb_sink* sink,
- int depth) {
+ int depth TSRMLS_DC) {
upb_sink subsink;
if (Z_TYPE_P(submsg) == IS_NULL) return;
@@ -1123,12 +1135,12 @@ static void putsubmsg(zval* submsg, const upb_fielddef* f, upb_sink* sink,
(Descriptor*)zend_object_store_get_object(php_descriptor TSRMLS_CC);
upb_sink_startsubmsg(sink, getsel(f, UPB_HANDLER_STARTSUBMSG), &subsink);
- putmsg(submsg, subdesc, &subsink, depth + 1);
+ putmsg(submsg, subdesc, &subsink, depth + 1 TSRMLS_CC);
upb_sink_endsubmsg(sink, getsel(f, UPB_HANDLER_ENDSUBMSG));
}
static void putarray(zval* array, const upb_fielddef* f, upb_sink* sink,
- int depth) {
+ int depth TSRMLS_DC) {
upb_sink subsink;
upb_fieldtype_t type = upb_fielddef_type(f);
upb_selector_t sel = 0;
@@ -1147,7 +1159,7 @@ static void putarray(zval* array, const upb_fielddef* f, upb_sink* sink,
}
for (i = 0; i < size; i++) {
- void* memory = repeated_field_index_native(intern, i);
+ void* memory = repeated_field_index_native(intern, i TSRMLS_CC);
switch (type) {
#define T(upbtypeconst, upbtype, ctype) \
case upbtypeconst: \
@@ -1168,7 +1180,7 @@ static void putarray(zval* array, const upb_fielddef* f, upb_sink* sink,
putstr(*((zval**)memory), f, &subsink);
break;
case UPB_TYPE_MESSAGE:
- putsubmsg(*((zval**)memory), f, &subsink, depth);
+ putsubmsg(*((zval**)memory), f, &subsink, depth TSRMLS_CC);
break;
#undef T
@@ -1206,7 +1218,7 @@ PHP_METHOD(Message, encode) {
stackenv_init(&se, "Error occurred during encoding: %s");
encoder = upb_pb_encoder_create(&se.env, serialize_handlers, &sink.sink);
- putmsg(getThis(), desc, upb_pb_encoder_input(encoder), 0);
+ putmsg(getThis(), desc, upb_pb_encoder_input(encoder), 0 TSRMLS_CC);
RETVAL_STRINGL(sink.ptr, sink.len, 1);
diff --git a/php/ext/google/protobuf/map.c b/php/ext/google/protobuf/map.c
index 6d822fff..35747b05 100644
--- a/php/ext/google/protobuf/map.c
+++ b/php/ext/google/protobuf/map.c
@@ -33,6 +33,7 @@
#include <Zend/zend_interfaces.h>
#include "protobuf.h"
+#include "utf8.h"
ZEND_BEGIN_ARG_INFO_EX(arginfo_offsetGet, 0, 0, 1)
ZEND_ARG_INFO(0, index)
@@ -88,7 +89,7 @@ void* upb_value_memory(upb_value* v) {
static bool table_key(Map* self, zval* key,
char* buf,
const char** out_key,
- size_t* out_length) {
+ size_t* out_length TSRMLS_DC) {
switch (self->key_type) {
case UPB_TYPE_STRING:
if (!protobuf_convert_to_string(key)) {
@@ -108,7 +109,7 @@ static bool table_key(Map* self, zval* key,
if (!protobuf_convert_to_##type(key, &type##_value)) { \
return false; \
} \
- native_slot_set(self->key_type, NULL, buf, key); \
+ native_slot_set(self->key_type, NULL, buf, key TSRMLS_CC); \
*out_key = buf; \
*out_length = native_slot_size(self->key_type); \
break; \
@@ -152,7 +153,7 @@ static zend_function_entry map_field_methods[] = {
zend_class_entry* map_field_type;
zend_object_handlers* map_field_handlers;
-static map_begin_internal(Map *map, MapIter *iter) {
+static void map_begin_internal(Map *map, MapIter *iter) {
iter->self = map;
upb_strtable_begin(&iter->it, &map->table);
}
@@ -248,7 +249,7 @@ void map_field_create_with_type(zend_class_entry *ce, const upb_fielddef *field,
const upb_fielddef *value_field = map_field_value(field);
intern->key_type = upb_fielddef_type(key_field);
intern->value_type = upb_fielddef_type(value_field);
- intern->msg_ce = field_type_class(value_field);
+ intern->msg_ce = field_type_class(value_field TSRMLS_CC);
}
static void map_field_free_element(void *object) {
@@ -258,8 +259,8 @@ static void map_field_free_element(void *object) {
// MapField Handlers
// -----------------------------------------------------------------------------
-static bool *map_field_read_dimension(zval *object, zval *key, int type,
- zval **retval TSRMLS_DC) {
+static bool map_field_read_dimension(zval *object, zval *key, int type,
+ zval **retval TSRMLS_DC) {
Map *intern =
(Map *)zend_object_store_get_object(object TSRMLS_CC);
@@ -270,7 +271,7 @@ static bool *map_field_read_dimension(zval *object, zval *key, int type,
#ifndef NDEBUG
v.ctype = UPB_CTYPE_UINT64;
#endif
- if (!table_key(intern, key, keybuf, &keyval, &length)) {
+ if (!table_key(intern, key, keybuf, &keyval, &length TSRMLS_CC)) {
return false;
}
@@ -303,13 +304,14 @@ static bool map_field_write_dimension(zval *object, zval *key,
size_t length = 0;
upb_value v;
void* mem;
- if (!table_key(intern, key, keybuf, &keyval, &length)) {
+ if (!table_key(intern, key, keybuf, &keyval, &length TSRMLS_CC)) {
return false;
}
mem = upb_value_memory(&v);
memset(mem, 0, native_slot_size(intern->value_type));
- if(!native_slot_set(intern->value_type, intern->msg_ce, mem, value)) {
+ if (!native_slot_set(intern->value_type, intern->msg_ce, mem, value
+ TSRMLS_CC)) {
return false;
}
#ifndef NDEBUG
@@ -333,7 +335,7 @@ static bool map_field_unset_dimension(zval *object, zval *key TSRMLS_DC) {
const char* keyval = NULL;
size_t length = 0;
upb_value v;
- if (!table_key(intern, key, keybuf, &keyval, &length)) {
+ if (!table_key(intern, key, keybuf, &keyval, &length TSRMLS_CC)) {
return false;
}
#ifndef NDEBUG
@@ -396,8 +398,8 @@ PHP_METHOD(MapField, offsetExists) {
#ifndef NDEBUG
v.ctype = UPB_CTYPE_UINT64;
#endif
- if (!table_key(intern, key, keybuf, &keyval, &length)) {
- return false;
+ if (!table_key(intern, key, keybuf, &keyval, &length TSRMLS_CC)) {
+ RETURN_BOOL(false);
}
RETURN_BOOL(upb_strtable_lookup2(&intern->table, keyval, length, &v));
@@ -433,7 +435,7 @@ PHP_METHOD(MapField, offsetUnset) {
PHP_METHOD(MapField, count) {
Map *intern =
- (MapField *)zend_object_store_get_object(getThis() TSRMLS_CC);
+ (Map *)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -446,7 +448,7 @@ PHP_METHOD(MapField, count) {
// Map Iterator
// -----------------------------------------------------------------------------
-void map_begin(zval *map_php, MapIter *iter) {
+void map_begin(zval *map_php, MapIter *iter TSRMLS_DC) {
Map *self = UNBOX(Map, map_php);
map_begin_internal(self, iter);
}
diff --git a/php/ext/google/protobuf/message.c b/php/ext/google/protobuf/message.c
index 0cae6dba..cb46031e 100644
--- a/php/ext/google/protobuf/message.c
+++ b/php/ext/google/protobuf/message.c
@@ -96,7 +96,7 @@ static void message_set_property(zval* object, zval* member, zval* value,
zend_error(E_USER_ERROR, "Unknown field: %s", Z_STRVAL_P(member));
}
- layout_set(self->descriptor->layout, self, field, value);
+ layout_set(self->descriptor->layout, self, field, value TSRMLS_CC);
}
static zval* message_get_property(zval* object, zval* member, int type,
@@ -177,7 +177,8 @@ static zend_object_value message_create(zend_class_entry* ce TSRMLS_DC) {
zend_object_std_init(&msg->std, ce TSRMLS_CC);
object_properties_init(&msg->std, ce);
- layout_init(desc->layout, message_data(msg), msg->std.properties_table);
+ layout_init(desc->layout, message_data(msg), msg->std.properties_table
+ TSRMLS_CC);
return_value.handle = zend_objects_store_put(
msg, (zend_objects_store_dtor_t)zend_objects_destroy_object, message_free,
diff --git a/php/ext/google/protobuf/package.xml b/php/ext/google/protobuf/package.xml
index 83719091..01aad411 100644
--- a/php/ext/google/protobuf/package.xml
+++ b/php/ext/google/protobuf/package.xml
@@ -6,15 +6,15 @@
<description>https://developers.google.com/protocol-buffers/</description>
<lead>
<name>Bo Yang</name>
- <user>teboring</user>
+ <user>stanleycheung</user>
<email>protobuf-opensource@google.com</email>
<active>yes</active>
</lead>
- <date>2016-09-02</date>
+ <date>2016-09-23</date>
<time>16:06:07</time>
<version>
- <release>3.1.0</release>
- <api>3.1.0</api>
+ <release>3.1.0a1</release>
+ <api>3.1.0a1</api>
</version>
<stability>
<release>alpha</release>
@@ -45,7 +45,7 @@ First alpha release.
<dependencies>
<required>
<php>
- <min>5.6.0</min>
+ <min>5.5.9</min>
</php>
<pearinstaller>
<min>1.4.0</min>
@@ -57,14 +57,15 @@ First alpha release.
<changelog>
<release>
<version>
- <release>3.1.0</release>
- <api>3.1.0</api>
+ <release>3.1.0a1</release>
+ <api>3.1.0a1</api>
</version>
<stability>
<release>alpha</release>
<api>alpha</api>
</stability>
- <date>2016-09-02</date>
+ <date>2016-09-23</date>
+ <time>16:06:07</time>
<license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license>
<notes>
First alpha release
diff --git a/php/ext/google/protobuf/protobuf.c b/php/ext/google/protobuf/protobuf.c
index d8ad3c88..019bca29 100644
--- a/php/ext/google/protobuf/protobuf.c
+++ b/php/ext/google/protobuf/protobuf.c
@@ -55,7 +55,7 @@ static void add_to_table(HashTable* t, const void* def, void* value) {
uint nIndex = (ulong)def & t->nTableMask;
zval* pDest = NULL;
- zend_hash_index_update(t, (zend_ulong)def, &value, sizeof(zval*), &pDest);
+ zend_hash_index_update(t, (zend_ulong)def, &value, sizeof(zval*), (void**)&pDest);
}
static void* get_from_table(const HashTable* t, const void* def) {
@@ -69,7 +69,7 @@ static void* get_from_table(const HashTable* t, const void* def) {
static void add_to_list(HashTable* t, void* value) {
zval* pDest = NULL;
- zend_hash_next_index_insert(t, &value, sizeof(void*), &pDest);
+ zend_hash_next_index_insert(t, &value, sizeof(void*), (void**)&pDest);
}
void add_def_obj(const void* def, zval* value) {
@@ -134,6 +134,8 @@ static PHP_RINIT_FUNCTION(protobuf) {
generated_pool = NULL;
generated_pool_php = NULL;
+
+ return 0;
}
static PHP_RSHUTDOWN_FUNCTION(protobuf) {
@@ -147,6 +149,8 @@ static PHP_RSHUTDOWN_FUNCTION(protobuf) {
zval_dtor(generated_pool_php);
FREE_ZVAL(generated_pool_php);
}
+
+ return 0;
}
static PHP_MINIT_FUNCTION(protobuf) {
@@ -158,10 +162,14 @@ static PHP_MINIT_FUNCTION(protobuf) {
descriptor_init(TSRMLS_C);
enum_descriptor_init(TSRMLS_C);
util_init(TSRMLS_C);
+
+ return 0;
}
static PHP_MSHUTDOWN_FUNCTION(protobuf) {
PEFREE(message_handlers);
PEFREE(repeated_field_handlers);
PEFREE(map_field_handlers);
+
+ return 0;
}
diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h
index 0330f36f..8a1d9261 100644
--- a/php/ext/google/protobuf/protobuf.h
+++ b/php/ext/google/protobuf/protobuf.h
@@ -37,7 +37,7 @@
#include "upb.h"
#define PHP_PROTOBUF_EXTNAME "protobuf"
-#define PHP_PROTOBUF_VERSION "0.01"
+#define PHP_PROTOBUF_VERSION "3.1.0a1"
// -----------------------------------------------------------------------------
// Forward Declaration
@@ -70,14 +70,6 @@ typedef struct MapField MapField;
ZEND_BEGIN_MODULE_GLOBALS(protobuf)
ZEND_END_MODULE_GLOBALS(protobuf)
-ZEND_DECLARE_MODULE_GLOBALS(protobuf)
-
-#ifdef ZTS
-#define PROTOBUF_G(v) TSRMG(protobuf_globals_id, zend_protobuf_globals*, v)
-#else
-#define PROTOBUF_G(v) (protobuf_globals.v)
-#endif
-
// Init module and PHP classes.
void descriptor_init(TSRMLS_D);
void enum_descriptor_init(TSRMLS_D);
@@ -233,11 +225,12 @@ struct MessageHeader {
};
MessageLayout* create_layout(const upb_msgdef* msgdef);
-void layout_init(MessageLayout* layout, void* storage, zval** properties_table);
+void layout_init(MessageLayout* layout, void* storage, zval** properties_table
+ TSRMLS_DC);
zval* layout_get(MessageLayout* layout, const void* storage,
const upb_fielddef* field, zval** cache TSRMLS_DC);
void layout_set(MessageLayout* layout, MessageHeader* header,
- const upb_fielddef* field, zval* val);
+ const upb_fielddef* field, zval* val TSRMLS_DC);
void free_layout(MessageLayout* layout);
PHP_METHOD(Message, readOneof);
@@ -293,7 +286,7 @@ PHP_METHOD(Util, checkRepeatedField);
size_t native_slot_size(upb_fieldtype_t type);
bool native_slot_set(upb_fieldtype_t type, const zend_class_entry* klass,
- void* memory, zval* value);
+ void* memory, zval* value TSRMLS_DC);
void native_slot_init(upb_fieldtype_t type, void* memory, zval** cache);
// For each property, in order to avoid conversion between the zval object and
// the actual data type during parsing/serialization, the containing message
@@ -325,7 +318,7 @@ typedef struct {
upb_strtable_iter it;
} MapIter;
-void map_begin(zval* self, MapIter* iter);
+void map_begin(zval* self, MapIter* iter TSRMLS_DC);
void map_next(MapIter* iter);
bool map_done(MapIter* iter);
const char* map_iter_key(MapIter* iter, int* len);
@@ -346,6 +339,7 @@ void* upb_value_memory(upb_value* v);
// These operate on a map field (i.e., a repeated field of submessages whose
// submessage type is a map-entry msgdef).
+bool is_map_field(const upb_fielddef* field);
const upb_fielddef* map_field_key(const upb_fielddef* field);
const upb_fielddef* map_field_value(const upb_fielddef* field);
@@ -377,10 +371,10 @@ void repeated_field_create_with_type(zend_class_entry* ce,
zval** repeated_field TSRMLS_DC);
// Return the element at the index position from the repeated field. There is
// not restriction on the type of stored elements.
-void *repeated_field_index_native(RepeatedField *intern, int index);
+void *repeated_field_index_native(RepeatedField *intern, int index TSRMLS_DC);
// Add the element to the end of the repeated field. There is not restriction on
// the type of stored elements.
-void repeated_field_push_native(RepeatedField *intern, void *value);
+void repeated_field_push_native(RepeatedField *intern, void *value TSRMLS_DC);
PHP_METHOD(RepeatedField, __construct);
PHP_METHOD(RepeatedField, append);
@@ -411,7 +405,7 @@ typedef struct {
// -----------------------------------------------------------------------------
upb_fieldtype_t to_fieldtype(upb_descriptortype_t type);
-const zend_class_entry *field_type_class(const upb_fielddef *field);
+const zend_class_entry *field_type_class(const upb_fielddef *field TSRMLS_DC);
// -----------------------------------------------------------------------------
// Utilities.
diff --git a/php/ext/google/protobuf/storage.c b/php/ext/google/protobuf/storage.c
index 7423552b..e94aa319 100644
--- a/php/ext/google/protobuf/storage.c
+++ b/php/ext/google/protobuf/storage.c
@@ -32,6 +32,8 @@
#include <protobuf.h>
#include <Zend/zend.h>
+#include "utf8.h"
+
// -----------------------------------------------------------------------------
// Native slot storage.
// -----------------------------------------------------------------------------
@@ -56,7 +58,7 @@ size_t native_slot_size(upb_fieldtype_t type) {
}
bool native_slot_set(upb_fieldtype_t type, const zend_class_entry* klass,
- void* memory, zval* value) {
+ void* memory, zval* value TSRMLS_DC) {
switch (type) {
case UPB_TYPE_STRING:
case UPB_TYPE_BYTES: {
@@ -210,7 +212,7 @@ CASE(ENUM, LONG, uint32_t)
return;
}
default:
- return EG(uninitialized_zval_ptr);
+ return;
}
}
@@ -245,7 +247,7 @@ void native_slot_get_default(upb_fieldtype_t type, zval** cache TSRMLS_DC) {
return;
}
default:
- return EG(uninitialized_zval_ptr);
+ return;
}
}
@@ -295,7 +297,7 @@ const upb_fielddef* map_entry_value(const upb_msgdef* msgdef) {
return value_field;
}
-const zend_class_entry* field_type_class(const upb_fielddef* field) {
+const zend_class_entry* field_type_class(const upb_fielddef* field TSRMLS_DC) {
if (upb_fielddef_type(field) == UPB_TYPE_MESSAGE) {
zval* desc_php = get_def_obj(upb_fielddef_subdef(field));
Descriptor* desc = zend_object_store_get_object(desc_php TSRMLS_CC);
@@ -305,6 +307,7 @@ const zend_class_entry* field_type_class(const upb_fielddef* field) {
EnumDescriptor* desc = zend_object_store_get_object(desc_php TSRMLS_CC);
return desc->klass;
}
+ return NULL;
}
// -----------------------------------------------------------------------------
@@ -435,7 +438,8 @@ void free_layout(MessageLayout* layout) {
FREE(layout);
}
-void layout_init(MessageLayout* layout, void* storage, zval** properties_table) {
+void layout_init(MessageLayout* layout, void* storage, zval** properties_table
+ TSRMLS_DC) {
int i;
upb_msg_field_iter it;
for (upb_msg_field_begin(&it, layout->msgdef), i = 0; !upb_msg_field_done(&it);
@@ -451,11 +455,12 @@ void layout_init(MessageLayout* layout, void* storage, zval** properties_table)
*oneof_case = ONEOF_CASE_NONE;
} else if (is_map_field(field)) {
zval_ptr_dtor(property_ptr);
- map_field_create_with_type(map_field_type, field, property_ptr);
+ map_field_create_with_type(map_field_type, field, property_ptr TSRMLS_CC);
DEREF(memory, zval**) = property_ptr;
} else if (upb_fielddef_label(field) == UPB_LABEL_REPEATED) {
zval_ptr_dtor(property_ptr);
- repeated_field_create_with_type(repeated_field_type, field, property_ptr);
+ repeated_field_create_with_type(repeated_field_type, field, property_ptr
+ TSRMLS_CC);
DEREF(memory, zval**) = property_ptr;
} else {
native_slot_init(upb_fielddef_type(field), memory, property_ptr);
@@ -501,8 +506,8 @@ zval* layout_get(MessageLayout* layout, const void* storage,
}
}
-void layout_set(MessageLayout* layout, MessageHeader* header, const upb_fielddef* field,
- zval* val) {
+void layout_set(MessageLayout* layout, MessageHeader* header,
+ const upb_fielddef* field, zval* val TSRMLS_DC) {
void* storage = message_data(header);
void* memory = slot_memory(layout, storage, field);
uint32_t* oneof_case = slot_oneof_case(layout, storage, field);
@@ -515,7 +520,7 @@ void layout_set(MessageLayout* layout, MessageHeader* header, const upb_fielddef
// zval in properties table first.
switch (type) {
case UPB_TYPE_MESSAGE: {
- upb_msgdef* msg = upb_fielddef_msgsubdef(field);
+ const upb_msgdef* msg = upb_fielddef_msgsubdef(field);
zval* desc_php = get_def_obj(msg);
Descriptor* desc = zend_object_store_get_object(desc_php TSRMLS_CC);
ce = desc->klass;
@@ -535,7 +540,7 @@ void layout_set(MessageLayout* layout, MessageHeader* header, const upb_fielddef
break;
}
- native_slot_set(type, ce, memory, val);
+ native_slot_set(type, ce, memory, val TSRMLS_CC);
*oneof_case = upb_fielddef_number(field);
} else if (upb_fielddef_label(field) == UPB_LABEL_REPEATED) {
// Works for both repeated and map fields
@@ -549,11 +554,11 @@ void layout_set(MessageLayout* layout, MessageHeader* header, const upb_fielddef
upb_fieldtype_t type = upb_fielddef_type(field);
zend_class_entry *ce = NULL;
if (type == UPB_TYPE_MESSAGE) {
- upb_msgdef* msg = upb_fielddef_msgsubdef(field);
+ const upb_msgdef* msg = upb_fielddef_msgsubdef(field);
zval* desc_php = get_def_obj(msg);
Descriptor* desc = zend_object_store_get_object(desc_php TSRMLS_CC);
ce = desc->klass;
}
- native_slot_set(type, ce, value_memory(field, memory), val);
+ native_slot_set(type, ce, value_memory(field, memory), val TSRMLS_CC);
}
}
diff --git a/php/ext/google/protobuf/type_check.c b/php/ext/google/protobuf/type_check.c
index fe9359fc..c215d72e 100644
--- a/php/ext/google/protobuf/type_check.c
+++ b/php/ext/google/protobuf/type_check.c
@@ -214,7 +214,6 @@ bool protobuf_convert_to_bool(zval* from, int8_t* to) {
} else {
*to = 1;
}
- STR_FREE(strval);
} break;
default: {
zend_error(E_USER_ERROR, "Given value cannot be converted to bool.");
diff --git a/php/ext/google/protobuf/utf8.c b/php/ext/google/protobuf/utf8.c
index a1541636..2752a08b 100644
--- a/php/ext/google/protobuf/utf8.c
+++ b/php/ext/google/protobuf/utf8.c
@@ -58,7 +58,7 @@ bool is_structurally_valid_utf8(const char* buf, int len) {
return false;
}
for (j = i + 1; j < i + offset; j++) {
- if (buf[j] & 0xc0 != 0x80) {
+ if ((buf[j] & 0xc0) != 0x80) {
return false;
}
}
diff --git a/php/src/Google/Protobuf/Internal/Message.php b/php/src/Google/Protobuf/Internal/Message.php
index a8de6a11..7bdc6a8c 100644
--- a/php/src/Google/Protobuf/Internal/Message.php
+++ b/php/src/Google/Protobuf/Internal/Message.php
@@ -81,41 +81,44 @@ class Message
switch ($value_field->getType()) {
case GPBType::MESSAGE:
case GPBType::GROUP:
- $this->$setter(
- new MapField(
- $key_field->getType(),
- $value_field->getType(),
- $value_field->getMessageType()->getClass()));
+ $map_field = new MapField(
+ $key_field->getType(),
+ $value_field->getType(),
+ $value_field->getMessageType()->getClass());
+ $this->$setter($map_field);
break;
case GPBType::ENUM:
- $this->$setter(
- new MapField(
- $key_field->getType(),
- $value_field->getType(),
- $value_field->getEnumType()->getClass()));
+ $map_field = new MapField(
+ $key_field->getType(),
+ $value_field->getType(),
+ $value_field->getEnumType()->getClass());
+ $this->$setter($map_field);
break;
default:
- $this->$setter(new MapField($key_field->getType(),
- $value_field->getType()));
+ $map_field = new MapField(
+ $key_field->getType(),
+ $value_field->getType());
+ $this->$setter($map_field);
break;
}
} else if ($field->getLabel() === GPBLabel::REPEATED) {
switch ($field->getType()) {
case GPBType::MESSAGE:
case GPBType::GROUP:
- $this->$setter(
- new RepeatedField(
- $field->getType(),
- $field->getMessageType()->getClass()));
+ $repeated_field = new RepeatedField(
+ $field->getType(),
+ $field->getMessageType()->getClass());
+ $this->$setter($repeated_field);
break;
case GPBType::ENUM:
- $this->$setter(
- new RepeatedField(
- $field->getType(),
- $field->getEnumType()->getClass()));
+ $repeated_field = new RepeatedField(
+ $field->getType(),
+ $field->getEnumType()->getClass());
+ $this->$setter($repeated_field);
break;
default:
- $this->$setter(new RepeatedField($field->getType()));
+ $repeated_field = new RepeatedField($field->getType());
+ $this->$setter($repeated_field);
break;
}
} else if ($field->getOneofIndex() !== -1) {
diff --git a/php/tests/array_test.php b/php/tests/array_test.php
index d683add5..09d4dc82 100644
--- a/php/tests/array_test.php
+++ b/php/tests/array_test.php
@@ -789,26 +789,26 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase
$this->assertSame(1, count($arr));
}
- public function testInsertRemoval()
- {
- $arr = new RepeatedField(GPBType::INT32);
-
- $arr []= 0;
- $arr []= 1;
- $arr []= 2;
- $this->assertSame(3, count($arr));
-
- unset($arr[2]);
- $this->assertSame(2, count($arr));
- $this->assertSame(0, $arr[0]);
- $this->assertSame(1, $arr[1]);
-
- $arr [] = 3;
- $this->assertSame(3, count($arr));
- $this->assertSame(0, $arr[0]);
- $this->assertSame(1, $arr[1]);
- $this->assertSame(3, $arr[2]);
- }
+ public function testInsertRemoval()
+ {
+ $arr = new RepeatedField(GPBType::INT32);
+
+ $arr []= 0;
+ $arr []= 1;
+ $arr []= 2;
+ $this->assertSame(3, count($arr));
+
+ unset($arr[2]);
+ $this->assertSame(2, count($arr));
+ $this->assertSame(0, $arr[0]);
+ $this->assertSame(1, $arr[1]);
+
+ $arr [] = 3;
+ $this->assertSame(3, count($arr));
+ $this->assertSame(0, $arr[0]);
+ $this->assertSame(1, $arr[1]);
+ $this->assertSame(3, $arr[2]);
+ }
/**
* @expectedException PHPUnit_Framework_Error
diff --git a/php/tests/test.pb.php b/php/tests/test.pb.php
new file mode 100644
index 00000000..ed316b6e
--- /dev/null
+++ b/php/tests/test.pb.php
@@ -0,0 +1,1385 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: test.proto
+
+namespace Foo;
+
+require_once('test_include.pb.php');
+use Google\Protobuf\Internal\DescriptorPool;
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\GPBUtil;
+
+class TestMessage extends \Google\Protobuf\Internal\Message
+{
+ private $optional_int32 = 0;
+ private $optional_int64 = 0;
+ private $optional_uint32 = 0;
+ private $optional_uint64 = 0;
+ private $optional_sint32 = 0;
+ private $optional_sint64 = 0;
+ private $optional_fixed32 = 0;
+ private $optional_fixed64 = 0;
+ private $optional_sfixed32 = 0;
+ private $optional_sfixed64 = 0;
+ private $optional_float = 0.0;
+ private $optional_double = 0.0;
+ private $optional_bool = false;
+ private $optional_string = '';
+ private $optional_bytes = '';
+ private $optional_enum = 0;
+ private $optional_message = null;
+ private $optional_included_message = null;
+ private $recursive = null;
+ private $repeated_int32;
+ private $repeated_int64;
+ private $repeated_uint32;
+ private $repeated_uint64;
+ private $repeated_sint32;
+ private $repeated_sint64;
+ private $repeated_fixed32;
+ private $repeated_fixed64;
+ private $repeated_sfixed32;
+ private $repeated_sfixed64;
+ private $repeated_float;
+ private $repeated_double;
+ private $repeated_bool;
+ private $repeated_string;
+ private $repeated_bytes;
+ private $repeated_enum;
+ private $repeated_message;
+ private $repeated_recursive;
+ private $map_int32_int32;
+ private $map_int64_int64;
+ private $map_uint32_uint32;
+ private $map_uint64_uint64;
+ private $map_sint32_sint32;
+ private $map_sint64_sint64;
+ private $map_fixed32_fixed32;
+ private $map_fixed64_fixed64;
+ private $map_sfixed32_sfixed32;
+ private $map_sfixed64_sfixed64;
+ private $map_int32_float;
+ private $map_int32_double;
+ private $map_bool_bool;
+ private $map_string_string;
+ private $map_int32_bytes;
+ private $map_int32_enum;
+ private $map_int32_message;
+ private $map_recursive;
+ protected $my_oneof;
+
+ public function getOptionalInt32()
+ {
+ return $this->optional_int32;
+ }
+
+ public function setOptionalInt32($var)
+ {
+ GPBUtil::checkInt32($var);
+ $this->optional_int32 = $var;
+ }
+
+ public function getOptionalInt64()
+ {
+ return $this->optional_int64;
+ }
+
+ public function setOptionalInt64($var)
+ {
+ GPBUtil::checkInt64($var);
+ $this->optional_int64 = $var;
+ }
+
+ public function getOptionalUint32()
+ {
+ return $this->optional_uint32;
+ }
+
+ public function setOptionalUint32($var)
+ {
+ GPBUtil::checkUint32($var);
+ $this->optional_uint32 = $var;
+ }
+
+ public function getOptionalUint64()
+ {
+ return $this->optional_uint64;
+ }
+
+ public function setOptionalUint64($var)
+ {
+ GPBUtil::checkUint64($var);
+ $this->optional_uint64 = $var;
+ }
+
+ public function getOptionalSint32()
+ {
+ return $this->optional_sint32;
+ }
+
+ public function setOptionalSint32($var)
+ {
+ GPBUtil::checkInt32($var);
+ $this->optional_sint32 = $var;
+ }
+
+ public function getOptionalSint64()
+ {
+ return $this->optional_sint64;
+ }
+
+ public function setOptionalSint64($var)
+ {
+ GPBUtil::checkInt64($var);
+ $this->optional_sint64 = $var;
+ }
+
+ public function getOptionalFixed32()
+ {
+ return $this->optional_fixed32;
+ }
+
+ public function setOptionalFixed32($var)
+ {
+ GPBUtil::checkUint32($var);
+ $this->optional_fixed32 = $var;
+ }
+
+ public function getOptionalFixed64()
+ {
+ return $this->optional_fixed64;
+ }
+
+ public function setOptionalFixed64($var)
+ {
+ GPBUtil::checkUint64($var);
+ $this->optional_fixed64 = $var;
+ }
+
+ public function getOptionalSfixed32()
+ {
+ return $this->optional_sfixed32;
+ }
+
+ public function setOptionalSfixed32($var)
+ {
+ GPBUtil::checkInt32($var);
+ $this->optional_sfixed32 = $var;
+ }
+
+ public function getOptionalSfixed64()
+ {
+ return $this->optional_sfixed64;
+ }
+
+ public function setOptionalSfixed64($var)
+ {
+ GPBUtil::checkInt64($var);
+ $this->optional_sfixed64 = $var;
+ }
+
+ public function getOptionalFloat()
+ {
+ return $this->optional_float;
+ }
+
+ public function setOptionalFloat($var)
+ {
+ GPBUtil::checkFloat($var);
+ $this->optional_float = $var;
+ }
+
+ public function getOptionalDouble()
+ {
+ return $this->optional_double;
+ }
+
+ public function setOptionalDouble($var)
+ {
+ GPBUtil::checkDouble($var);
+ $this->optional_double = $var;
+ }
+
+ public function getOptionalBool()
+ {
+ return $this->optional_bool;
+ }
+
+ public function setOptionalBool($var)
+ {
+ GPBUtil::checkBool($var);
+ $this->optional_bool = $var;
+ }
+
+ public function getOptionalString()
+ {
+ return $this->optional_string;
+ }
+
+ public function setOptionalString($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->optional_string = $var;
+ }
+
+ public function getOptionalBytes()
+ {
+ return $this->optional_bytes;
+ }
+
+ public function setOptionalBytes($var)
+ {
+ GPBUtil::checkString($var, False);
+ $this->optional_bytes = $var;
+ }
+
+ public function getOptionalEnum()
+ {
+ return $this->optional_enum;
+ }
+
+ public function setOptionalEnum($var)
+ {
+ GPBUtil::checkEnum($var, \Foo\TestEnum::class);
+ $this->optional_enum = $var;
+ }
+
+ public function getOptionalMessage()
+ {
+ return $this->optional_message;
+ }
+
+ public function setOptionalMessage(&$var)
+ {
+ GPBUtil::checkMessage($var, \Foo\TestMessage_Sub::class);
+ $this->optional_message = $var;
+ }
+
+ public function getOptionalIncludedMessage()
+ {
+ return $this->optional_included_message;
+ }
+
+ public function setOptionalIncludedMessage(&$var)
+ {
+ GPBUtil::checkMessage($var, \Bar\TestInclude::class);
+ $this->optional_included_message = $var;
+ }
+
+ public function getRecursive()
+ {
+ return $this->recursive;
+ }
+
+ public function setRecursive(&$var)
+ {
+ GPBUtil::checkMessage($var, \Foo\TestMessage::class);
+ $this->recursive = $var;
+ }
+
+ public function getRepeatedInt32()
+ {
+ return $this->repeated_int32;
+ }
+
+ public function setRepeatedInt32(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::INT32);
+ $this->repeated_int32 = $var;
+ }
+
+ public function getRepeatedInt64()
+ {
+ return $this->repeated_int64;
+ }
+
+ public function setRepeatedInt64(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::INT64);
+ $this->repeated_int64 = $var;
+ }
+
+ public function getRepeatedUint32()
+ {
+ return $this->repeated_uint32;
+ }
+
+ public function setRepeatedUint32(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::UINT32);
+ $this->repeated_uint32 = $var;
+ }
+
+ public function getRepeatedUint64()
+ {
+ return $this->repeated_uint64;
+ }
+
+ public function setRepeatedUint64(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::UINT64);
+ $this->repeated_uint64 = $var;
+ }
+
+ public function getRepeatedSint32()
+ {
+ return $this->repeated_sint32;
+ }
+
+ public function setRepeatedSint32(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::SINT32);
+ $this->repeated_sint32 = $var;
+ }
+
+ public function getRepeatedSint64()
+ {
+ return $this->repeated_sint64;
+ }
+
+ public function setRepeatedSint64(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::SINT64);
+ $this->repeated_sint64 = $var;
+ }
+
+ public function getRepeatedFixed32()
+ {
+ return $this->repeated_fixed32;
+ }
+
+ public function setRepeatedFixed32(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::FIXED32);
+ $this->repeated_fixed32 = $var;
+ }
+
+ public function getRepeatedFixed64()
+ {
+ return $this->repeated_fixed64;
+ }
+
+ public function setRepeatedFixed64(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::FIXED64);
+ $this->repeated_fixed64 = $var;
+ }
+
+ public function getRepeatedSfixed32()
+ {
+ return $this->repeated_sfixed32;
+ }
+
+ public function setRepeatedSfixed32(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::SFIXED32);
+ $this->repeated_sfixed32 = $var;
+ }
+
+ public function getRepeatedSfixed64()
+ {
+ return $this->repeated_sfixed64;
+ }
+
+ public function setRepeatedSfixed64(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::SFIXED64);
+ $this->repeated_sfixed64 = $var;
+ }
+
+ public function getRepeatedFloat()
+ {
+ return $this->repeated_float;
+ }
+
+ public function setRepeatedFloat(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::FLOAT);
+ $this->repeated_float = $var;
+ }
+
+ public function getRepeatedDouble()
+ {
+ return $this->repeated_double;
+ }
+
+ public function setRepeatedDouble(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::DOUBLE);
+ $this->repeated_double = $var;
+ }
+
+ public function getRepeatedBool()
+ {
+ return $this->repeated_bool;
+ }
+
+ public function setRepeatedBool(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::BOOL);
+ $this->repeated_bool = $var;
+ }
+
+ public function getRepeatedString()
+ {
+ return $this->repeated_string;
+ }
+
+ public function setRepeatedString(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::STRING);
+ $this->repeated_string = $var;
+ }
+
+ public function getRepeatedBytes()
+ {
+ return $this->repeated_bytes;
+ }
+
+ public function setRepeatedBytes(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::BYTES);
+ $this->repeated_bytes = $var;
+ }
+
+ public function getRepeatedEnum()
+ {
+ return $this->repeated_enum;
+ }
+
+ public function setRepeatedEnum(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::ENUM, Foo\TestEnum::class);
+ $this->repeated_enum = $var;
+ }
+
+ public function getRepeatedMessage()
+ {
+ return $this->repeated_message;
+ }
+
+ public function setRepeatedMessage(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Foo\TestMessage_Sub::class);
+ $this->repeated_message = $var;
+ }
+
+ public function getRepeatedRecursive()
+ {
+ return $this->repeated_recursive;
+ }
+
+ public function setRepeatedRecursive(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Foo\TestMessage::class);
+ $this->repeated_recursive = $var;
+ }
+
+ public function getOneofInt32()
+ {
+ return $this->readOneof(51);
+ }
+
+ public function setOneofInt32($var)
+ {
+ GPBUtil::checkInt32($var);
+ $this->writeOneof(51, $var);
+ }
+
+ public function getOneofInt64()
+ {
+ return $this->readOneof(52);
+ }
+
+ public function setOneofInt64($var)
+ {
+ GPBUtil::checkInt64($var);
+ $this->writeOneof(52, $var);
+ }
+
+ public function getOneofUint32()
+ {
+ return $this->readOneof(53);
+ }
+
+ public function setOneofUint32($var)
+ {
+ GPBUtil::checkUint32($var);
+ $this->writeOneof(53, $var);
+ }
+
+ public function getOneofUint64()
+ {
+ return $this->readOneof(54);
+ }
+
+ public function setOneofUint64($var)
+ {
+ GPBUtil::checkUint64($var);
+ $this->writeOneof(54, $var);
+ }
+
+ public function getOneofSint32()
+ {
+ return $this->readOneof(55);
+ }
+
+ public function setOneofSint32($var)
+ {
+ GPBUtil::checkUint32($var);
+ $this->writeOneof(55, $var);
+ }
+
+ public function getOneofSint64()
+ {
+ return $this->readOneof(56);
+ }
+
+ public function setOneofSint64($var)
+ {
+ GPBUtil::checkUint64($var);
+ $this->writeOneof(56, $var);
+ }
+
+ public function getOneofFixed32()
+ {
+ return $this->readOneof(57);
+ }
+
+ public function setOneofFixed32($var)
+ {
+ GPBUtil::checkUint32($var);
+ $this->writeOneof(57, $var);
+ }
+
+ public function getOneofFixed64()
+ {
+ return $this->readOneof(58);
+ }
+
+ public function setOneofFixed64($var)
+ {
+ GPBUtil::checkUint64($var);
+ $this->writeOneof(58, $var);
+ }
+
+ public function getOneofSfixed32()
+ {
+ return $this->readOneof(59);
+ }
+
+ public function setOneofSfixed32($var)
+ {
+ GPBUtil::checkUint32($var);
+ $this->writeOneof(59, $var);
+ }
+
+ public function getOneofSfixed64()
+ {
+ return $this->readOneof(60);
+ }
+
+ public function setOneofSfixed64($var)
+ {
+ GPBUtil::checkUint64($var);
+ $this->writeOneof(60, $var);
+ }
+
+ public function getOneofDouble()
+ {
+ return $this->readOneof(61);
+ }
+
+ public function setOneofDouble($var)
+ {
+ GPBUtil::checkDouble($var);
+ $this->writeOneof(61, $var);
+ }
+
+ public function getOneofFloat()
+ {
+ return $this->readOneof(62);
+ }
+
+ public function setOneofFloat($var)
+ {
+ GPBUtil::checkFloat($var);
+ $this->writeOneof(62, $var);
+ }
+
+ public function getOneofBool()
+ {
+ return $this->readOneof(63);
+ }
+
+ public function setOneofBool($var)
+ {
+ GPBUtil::checkBool($var);
+ $this->writeOneof(63, $var);
+ }
+
+ public function getOneofString()
+ {
+ return $this->readOneof(64);
+ }
+
+ public function setOneofString($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->writeOneof(64, $var);
+ }
+
+ public function getOneofBytes()
+ {
+ return $this->readOneof(65);
+ }
+
+ public function setOneofBytes($var)
+ {
+ GPBUtil::checkString($var, False);
+ $this->writeOneof(65, $var);
+ }
+
+ public function getOneofEnum()
+ {
+ return $this->readOneof(66);
+ }
+
+ public function setOneofEnum($var)
+ {
+ GPBUtil::checkEnum($var, \Foo\TestEnum::class);
+ $this->writeOneof(66, $var);
+ }
+
+ public function getOneofMessage()
+ {
+ return $this->readOneof(67);
+ }
+
+ public function setOneofMessage(&$var)
+ {
+ GPBUtil::checkMessage($var, \Foo\TestMessage_Sub::class);
+ $this->writeOneof(67, $var);
+ }
+
+ public function getMapInt32Int32()
+ {
+ return $this->map_int32_int32;
+ }
+
+ public function setMapInt32Int32(&$var)
+ {
+ $this->map_int32_int32 = $var;
+ }
+
+ public function getMapInt64Int64()
+ {
+ return $this->map_int64_int64;
+ }
+
+ public function setMapInt64Int64(&$var)
+ {
+ $this->map_int64_int64 = $var;
+ }
+
+ public function getMapUint32Uint32()
+ {
+ return $this->map_uint32_uint32;
+ }
+
+ public function setMapUint32Uint32(&$var)
+ {
+ $this->map_uint32_uint32 = $var;
+ }
+
+ public function getMapUint64Uint64()
+ {
+ return $this->map_uint64_uint64;
+ }
+
+ public function setMapUint64Uint64(&$var)
+ {
+ $this->map_uint64_uint64 = $var;
+ }
+
+ public function getMapSint32Sint32()
+ {
+ return $this->map_sint32_sint32;
+ }
+
+ public function setMapSint32Sint32(&$var)
+ {
+ $this->map_sint32_sint32 = $var;
+ }
+
+ public function getMapSint64Sint64()
+ {
+ return $this->map_sint64_sint64;
+ }
+
+ public function setMapSint64Sint64(&$var)
+ {
+ $this->map_sint64_sint64 = $var;
+ }
+
+ public function getMapFixed32Fixed32()
+ {
+ return $this->map_fixed32_fixed32;
+ }
+
+ public function setMapFixed32Fixed32(&$var)
+ {
+ $this->map_fixed32_fixed32 = $var;
+ }
+
+ public function getMapFixed64Fixed64()
+ {
+ return $this->map_fixed64_fixed64;
+ }
+
+ public function setMapFixed64Fixed64(&$var)
+ {
+ $this->map_fixed64_fixed64 = $var;
+ }
+
+ public function getMapSfixed32Sfixed32()
+ {
+ return $this->map_sfixed32_sfixed32;
+ }
+
+ public function setMapSfixed32Sfixed32(&$var)
+ {
+ $this->map_sfixed32_sfixed32 = $var;
+ }
+
+ public function getMapSfixed64Sfixed64()
+ {
+ return $this->map_sfixed64_sfixed64;
+ }
+
+ public function setMapSfixed64Sfixed64(&$var)
+ {
+ $this->map_sfixed64_sfixed64 = $var;
+ }
+
+ public function getMapInt32Float()
+ {
+ return $this->map_int32_float;
+ }
+
+ public function setMapInt32Float(&$var)
+ {
+ $this->map_int32_float = $var;
+ }
+
+ public function getMapInt32Double()
+ {
+ return $this->map_int32_double;
+ }
+
+ public function setMapInt32Double(&$var)
+ {
+ $this->map_int32_double = $var;
+ }
+
+ public function getMapBoolBool()
+ {
+ return $this->map_bool_bool;
+ }
+
+ public function setMapBoolBool(&$var)
+ {
+ $this->map_bool_bool = $var;
+ }
+
+ public function getMapStringString()
+ {
+ return $this->map_string_string;
+ }
+
+ public function setMapStringString(&$var)
+ {
+ $this->map_string_string = $var;
+ }
+
+ public function getMapInt32Bytes()
+ {
+ return $this->map_int32_bytes;
+ }
+
+ public function setMapInt32Bytes(&$var)
+ {
+ $this->map_int32_bytes = $var;
+ }
+
+ public function getMapInt32Enum()
+ {
+ return $this->map_int32_enum;
+ }
+
+ public function setMapInt32Enum(&$var)
+ {
+ $this->map_int32_enum = $var;
+ }
+
+ public function getMapInt32Message()
+ {
+ return $this->map_int32_message;
+ }
+
+ public function setMapInt32Message(&$var)
+ {
+ $this->map_int32_message = $var;
+ }
+
+ public function getMapRecursive()
+ {
+ return $this->map_recursive;
+ }
+
+ public function setMapRecursive(&$var)
+ {
+ $this->map_recursive = $var;
+ }
+
+ public function getMyOneof()
+ {
+ return $this->my_oneof;
+ }
+
+}
+
+class TestMessage_Sub extends \Google\Protobuf\Internal\Message
+{
+ private $a = 0;
+
+ public function getA()
+ {
+ return $this->a;
+ }
+
+ public function setA($var)
+ {
+ GPBUtil::checkInt32($var);
+ $this->a = $var;
+ }
+
+}
+
+class TestPackedMessage extends \Google\Protobuf\Internal\Message
+{
+ private $repeated_int32;
+ private $repeated_int64;
+ private $repeated_uint32;
+ private $repeated_uint64;
+ private $repeated_sint32;
+ private $repeated_sint64;
+ private $repeated_fixed32;
+ private $repeated_fixed64;
+ private $repeated_sfixed32;
+ private $repeated_sfixed64;
+ private $repeated_float;
+ private $repeated_double;
+ private $repeated_bool;
+ private $repeated_enum;
+
+ public function getRepeatedInt32()
+ {
+ return $this->repeated_int32;
+ }
+
+ public function setRepeatedInt32(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::INT32);
+ $this->repeated_int32 = $var;
+ }
+
+ public function getRepeatedInt64()
+ {
+ return $this->repeated_int64;
+ }
+
+ public function setRepeatedInt64(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::INT64);
+ $this->repeated_int64 = $var;
+ }
+
+ public function getRepeatedUint32()
+ {
+ return $this->repeated_uint32;
+ }
+
+ public function setRepeatedUint32(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::UINT32);
+ $this->repeated_uint32 = $var;
+ }
+
+ public function getRepeatedUint64()
+ {
+ return $this->repeated_uint64;
+ }
+
+ public function setRepeatedUint64(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::UINT64);
+ $this->repeated_uint64 = $var;
+ }
+
+ public function getRepeatedSint32()
+ {
+ return $this->repeated_sint32;
+ }
+
+ public function setRepeatedSint32(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::SINT32);
+ $this->repeated_sint32 = $var;
+ }
+
+ public function getRepeatedSint64()
+ {
+ return $this->repeated_sint64;
+ }
+
+ public function setRepeatedSint64(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::SINT64);
+ $this->repeated_sint64 = $var;
+ }
+
+ public function getRepeatedFixed32()
+ {
+ return $this->repeated_fixed32;
+ }
+
+ public function setRepeatedFixed32(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::FIXED32);
+ $this->repeated_fixed32 = $var;
+ }
+
+ public function getRepeatedFixed64()
+ {
+ return $this->repeated_fixed64;
+ }
+
+ public function setRepeatedFixed64(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::FIXED64);
+ $this->repeated_fixed64 = $var;
+ }
+
+ public function getRepeatedSfixed32()
+ {
+ return $this->repeated_sfixed32;
+ }
+
+ public function setRepeatedSfixed32(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::SFIXED32);
+ $this->repeated_sfixed32 = $var;
+ }
+
+ public function getRepeatedSfixed64()
+ {
+ return $this->repeated_sfixed64;
+ }
+
+ public function setRepeatedSfixed64(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::SFIXED64);
+ $this->repeated_sfixed64 = $var;
+ }
+
+ public function getRepeatedFloat()
+ {
+ return $this->repeated_float;
+ }
+
+ public function setRepeatedFloat(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::FLOAT);
+ $this->repeated_float = $var;
+ }
+
+ public function getRepeatedDouble()
+ {
+ return $this->repeated_double;
+ }
+
+ public function setRepeatedDouble(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::DOUBLE);
+ $this->repeated_double = $var;
+ }
+
+ public function getRepeatedBool()
+ {
+ return $this->repeated_bool;
+ }
+
+ public function setRepeatedBool(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::BOOL);
+ $this->repeated_bool = $var;
+ }
+
+ public function getRepeatedEnum()
+ {
+ return $this->repeated_enum;
+ }
+
+ public function setRepeatedEnum(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::ENUM, Foo\TestEnum::class);
+ $this->repeated_enum = $var;
+ }
+
+}
+
+class TestUnpackedMessage extends \Google\Protobuf\Internal\Message
+{
+ private $repeated_int32;
+ private $repeated_int64;
+ private $repeated_uint32;
+ private $repeated_uint64;
+ private $repeated_sint32;
+ private $repeated_sint64;
+ private $repeated_fixed32;
+ private $repeated_fixed64;
+ private $repeated_sfixed32;
+ private $repeated_sfixed64;
+ private $repeated_float;
+ private $repeated_double;
+ private $repeated_bool;
+ private $repeated_enum;
+
+ public function getRepeatedInt32()
+ {
+ return $this->repeated_int32;
+ }
+
+ public function setRepeatedInt32(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::INT32);
+ $this->repeated_int32 = $var;
+ }
+
+ public function getRepeatedInt64()
+ {
+ return $this->repeated_int64;
+ }
+
+ public function setRepeatedInt64(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::INT64);
+ $this->repeated_int64 = $var;
+ }
+
+ public function getRepeatedUint32()
+ {
+ return $this->repeated_uint32;
+ }
+
+ public function setRepeatedUint32(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::UINT32);
+ $this->repeated_uint32 = $var;
+ }
+
+ public function getRepeatedUint64()
+ {
+ return $this->repeated_uint64;
+ }
+
+ public function setRepeatedUint64(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::UINT64);
+ $this->repeated_uint64 = $var;
+ }
+
+ public function getRepeatedSint32()
+ {
+ return $this->repeated_sint32;
+ }
+
+ public function setRepeatedSint32(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::SINT32);
+ $this->repeated_sint32 = $var;
+ }
+
+ public function getRepeatedSint64()
+ {
+ return $this->repeated_sint64;
+ }
+
+ public function setRepeatedSint64(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::SINT64);
+ $this->repeated_sint64 = $var;
+ }
+
+ public function getRepeatedFixed32()
+ {
+ return $this->repeated_fixed32;
+ }
+
+ public function setRepeatedFixed32(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::FIXED32);
+ $this->repeated_fixed32 = $var;
+ }
+
+ public function getRepeatedFixed64()
+ {
+ return $this->repeated_fixed64;
+ }
+
+ public function setRepeatedFixed64(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::FIXED64);
+ $this->repeated_fixed64 = $var;
+ }
+
+ public function getRepeatedSfixed32()
+ {
+ return $this->repeated_sfixed32;
+ }
+
+ public function setRepeatedSfixed32(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::SFIXED32);
+ $this->repeated_sfixed32 = $var;
+ }
+
+ public function getRepeatedSfixed64()
+ {
+ return $this->repeated_sfixed64;
+ }
+
+ public function setRepeatedSfixed64(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::SFIXED64);
+ $this->repeated_sfixed64 = $var;
+ }
+
+ public function getRepeatedFloat()
+ {
+ return $this->repeated_float;
+ }
+
+ public function setRepeatedFloat(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::FLOAT);
+ $this->repeated_float = $var;
+ }
+
+ public function getRepeatedDouble()
+ {
+ return $this->repeated_double;
+ }
+
+ public function setRepeatedDouble(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::DOUBLE);
+ $this->repeated_double = $var;
+ }
+
+ public function getRepeatedBool()
+ {
+ return $this->repeated_bool;
+ }
+
+ public function setRepeatedBool(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::BOOL);
+ $this->repeated_bool = $var;
+ }
+
+ public function getRepeatedEnum()
+ {
+ return $this->repeated_enum;
+ }
+
+ public function setRepeatedEnum(&$var)
+ {
+ GPBUtil::checkRepeatedField($var, GPBType::ENUM, Foo\TestEnum::class);
+ $this->repeated_enum = $var;
+ }
+
+}
+
+class TestEnum
+{
+ const ZERO = 0;
+ const ONE = 1;
+}
+
+$pool = DescriptorPool::getGeneratedPool();
+
+$pool->internalAddGeneratedFile(hex2bin(
+ "0a83250a0a746573742e70726f746f1203666f6f1a12746573745f696e63" .
+ "6c7564652e70726f746f22be1d0a0b546573744d65737361676512160a0e" .
+ "6f7074696f6e616c5f696e74333218012001280512160a0e6f7074696f6e" .
+ "616c5f696e74363418022001280312170a0f6f7074696f6e616c5f75696e" .
+ "74333218032001280d12170a0f6f7074696f6e616c5f75696e7436341804" .
+ "2001280412170a0f6f7074696f6e616c5f73696e74333218052001281112" .
+ "170a0f6f7074696f6e616c5f73696e74363418062001281212180a106f70" .
+ "74696f6e616c5f6669786564333218072001280712180a106f7074696f6e" .
+ "616c5f6669786564363418082001280612190a116f7074696f6e616c5f73" .
+ "6669786564333218092001280f12190a116f7074696f6e616c5f73666978" .
+ "65643634180a2001281012160a0e6f7074696f6e616c5f666c6f6174180b" .
+ "2001280212170a0f6f7074696f6e616c5f646f75626c65180c2001280112" .
+ "150a0d6f7074696f6e616c5f626f6f6c180d2001280812170a0f6f707469" .
+ "6f6e616c5f737472696e67180e2001280912160a0e6f7074696f6e616c5f" .
+ "6279746573180f2001280c12240a0d6f7074696f6e616c5f656e756d1810" .
+ "2001280e320d2e666f6f2e54657374456e756d122e0a106f7074696f6e61" .
+ "6c5f6d65737361676518112001280b32142e666f6f2e546573744d657373" .
+ "6167652e53756212330a196f7074696f6e616c5f696e636c756465645f6d" .
+ "65737361676518122001280b32102e6261722e54657374496e636c756465" .
+ "12230a0972656375727369766518132001280b32102e666f6f2e54657374" .
+ "4d65737361676512160a0e72657065617465645f696e743332181f200328" .
+ "0512160a0e72657065617465645f696e74363418202003280312170a0f72" .
+ "657065617465645f75696e74333218212003280d12170a0f726570656174" .
+ "65645f75696e74363418222003280412170a0f72657065617465645f7369" .
+ "6e74333218232003281112170a0f72657065617465645f73696e74363418" .
+ "242003281212180a1072657065617465645f666978656433321825200328" .
+ "0712180a1072657065617465645f6669786564363418262003280612190a" .
+ "1172657065617465645f736669786564333218272003280f12190a117265" .
+ "7065617465645f736669786564363418282003281012160a0e7265706561" .
+ "7465645f666c6f617418292003280212170a0f72657065617465645f646f" .
+ "75626c65182a2003280112150a0d72657065617465645f626f6f6c182b20" .
+ "03280812170a0f72657065617465645f737472696e67182c200328091216" .
+ "0a0e72657065617465645f6279746573182d2003280c12240a0d72657065" .
+ "617465645f656e756d182e2003280e320d2e666f6f2e54657374456e756d" .
+ "122e0a1072657065617465645f6d657373616765182f2003280b32142e66" .
+ "6f6f2e546573744d6573736167652e537562122c0a127265706561746564" .
+ "5f72656375727369766518302003280b32102e666f6f2e546573744d6573" .
+ "7361676512150a0b6f6e656f665f696e743332183320012805480012150a" .
+ "0b6f6e656f665f696e743634183420012803480012160a0c6f6e656f665f" .
+ "75696e74333218352001280d480012160a0c6f6e656f665f75696e743634" .
+ "183620012804480012160a0c6f6e656f665f73696e74333218372001280d" .
+ "480012160a0c6f6e656f665f73696e743634183820012804480012170a0d" .
+ "6f6e656f665f6669786564333218392001280d480012170a0d6f6e656f66" .
+ "5f66697865643634183a20012804480012180a0e6f6e656f665f73666978" .
+ "65643332183b2001280d480012180a0e6f6e656f665f7366697865643634" .
+ "183c20012804480012160a0c6f6e656f665f646f75626c65183d20012801" .
+ "480012150a0b6f6e656f665f666c6f6174183e20012802480012140a0a6f" .
+ "6e656f665f626f6f6c183f20012808480012160a0c6f6e656f665f737472" .
+ "696e67184020012809480012150a0b6f6e656f665f627974657318412001" .
+ "280c480012230a0a6f6e656f665f656e756d18422001280e320d2e666f6f" .
+ "2e54657374456e756d4800122d0a0d6f6e656f665f6d6573736167651843" .
+ "2001280b32142e666f6f2e546573744d6573736167652e5375624800123c" .
+ "0a0f6d61705f696e7433325f696e74333218472003280b32232e666f6f2e" .
+ "546573744d6573736167652e4d6170496e743332496e743332456e747279" .
+ "123c0a0f6d61705f696e7436345f696e74363418482003280b32232e666f" .
+ "6f2e546573744d6573736167652e4d6170496e743634496e743634456e74" .
+ "727912400a116d61705f75696e7433325f75696e74333218492003280b32" .
+ "252e666f6f2e546573744d6573736167652e4d617055696e74333255696e" .
+ "743332456e74727912400a116d61705f75696e7436345f75696e74363418" .
+ "4a2003280b32252e666f6f2e546573744d6573736167652e4d617055696e" .
+ "74363455696e743634456e74727912400a116d61705f73696e7433325f73" .
+ "696e743332184b2003280b32252e666f6f2e546573744d6573736167652e" .
+ "4d617053696e74333253696e743332456e74727912400a116d61705f7369" .
+ "6e7436345f73696e743634184c2003280b32252e666f6f2e546573744d65" .
+ "73736167652e4d617053696e74363453696e743634456e74727912440a13" .
+ "6d61705f666978656433325f66697865643332184d2003280b32272e666f" .
+ "6f2e546573744d6573736167652e4d617046697865643332466978656433" .
+ "32456e74727912440a136d61705f666978656436345f6669786564363418" .
+ "4e2003280b32272e666f6f2e546573744d6573736167652e4d6170466978" .
+ "6564363446697865643634456e74727912480a156d61705f736669786564" .
+ "33325f7366697865643332184f2003280b32292e666f6f2e546573744d65" .
+ "73736167652e4d617053666978656433325366697865643332456e747279" .
+ "12480a156d61705f73666978656436345f73666978656436341850200328" .
+ "0b32292e666f6f2e546573744d6573736167652e4d617053666978656436" .
+ "345366697865643634456e747279123c0a0f6d61705f696e7433325f666c" .
+ "6f617418512003280b32232e666f6f2e546573744d6573736167652e4d61" .
+ "70496e743332466c6f6174456e747279123e0a106d61705f696e7433325f" .
+ "646f75626c6518522003280b32242e666f6f2e546573744d657373616765" .
+ "2e4d6170496e743332446f75626c65456e74727912380a0d6d61705f626f" .
+ "6f6c5f626f6f6c18532003280b32212e666f6f2e546573744d6573736167" .
+ "652e4d6170426f6f6c426f6f6c456e74727912400a116d61705f73747269" .
+ "6e675f737472696e6718542003280b32252e666f6f2e546573744d657373" .
+ "6167652e4d6170537472696e67537472696e67456e747279123c0a0f6d61" .
+ "705f696e7433325f627974657318552003280b32232e666f6f2e54657374" .
+ "4d6573736167652e4d6170496e7433324279746573456e747279123a0a0e" .
+ "6d61705f696e7433325f656e756d18562003280b32222e666f6f2e546573" .
+ "744d6573736167652e4d6170496e743332456e756d456e74727912400a11" .
+ "6d61705f696e7433325f6d65737361676518572003280b32252e666f6f2e" .
+ "546573744d6573736167652e4d6170496e7433324d657373616765456e74" .
+ "727912390a0d6d61705f72656375727369766518582003280b32222e666f" .
+ "6f2e546573744d6573736167652e4d6170526563757273697665456e7472" .
+ "791a340a124d6170496e743332496e743332456e747279120b0a036b6579" .
+ "180120012805120d0a0576616c75651802200128053a0238011a340a124d" .
+ "6170496e743634496e743634456e747279120b0a036b6579180120012803" .
+ "120d0a0576616c75651802200128033a0238011a360a144d617055696e74" .
+ "333255696e743332456e747279120b0a036b657918012001280d120d0a05" .
+ "76616c756518022001280d3a0238011a360a144d617055696e7436345569" .
+ "6e743634456e747279120b0a036b6579180120012804120d0a0576616c75" .
+ "651802200128043a0238011a360a144d617053696e74333253696e743332" .
+ "456e747279120b0a036b6579180120012811120d0a0576616c7565180220" .
+ "0128113a0238011a360a144d617053696e74363453696e743634456e7472" .
+ "79120b0a036b6579180120012812120d0a0576616c75651802200128123a" .
+ "0238011a380a164d61704669786564333246697865643332456e74727912" .
+ "0b0a036b6579180120012807120d0a0576616c75651802200128073a0238" .
+ "011a380a164d61704669786564363446697865643634456e747279120b0a" .
+ "036b6579180120012806120d0a0576616c75651802200128063a0238011a" .
+ "3a0a184d617053666978656433325366697865643332456e747279120b0a" .
+ "036b657918012001280f120d0a0576616c756518022001280f3a0238011a" .
+ "3a0a184d617053666978656436345366697865643634456e747279120b0a" .
+ "036b6579180120012810120d0a0576616c75651802200128103a0238011a" .
+ "340a124d6170496e743332466c6f6174456e747279120b0a036b65791801" .
+ "20012805120d0a0576616c75651802200128023a0238011a350a134d6170" .
+ "496e743332446f75626c65456e747279120b0a036b657918012001280512" .
+ "0d0a0576616c75651802200128013a0238011a320a104d6170426f6f6c42" .
+ "6f6f6c456e747279120b0a036b6579180120012808120d0a0576616c7565" .
+ "1802200128083a0238011a360a144d6170537472696e67537472696e6745" .
+ "6e747279120b0a036b6579180120012809120d0a0576616c756518022001" .
+ "28093a0238011a340a124d6170496e7433324279746573456e747279120b" .
+ "0a036b6579180120012805120d0a0576616c756518022001280c3a023801" .
+ "1a420a114d6170496e743332456e756d456e747279120b0a036b65791801" .
+ "20012805121c0a0576616c756518022001280e320d2e666f6f2e54657374" .
+ "456e756d3a0238011a4c0a144d6170496e7433324d657373616765456e74" .
+ "7279120b0a036b657918012001280512230a0576616c756518022001280b" .
+ "32142e666f6f2e546573744d6573736167652e5375623a0238011a450a11" .
+ "4d6170526563757273697665456e747279120b0a036b6579180120012805" .
+ "121f0a0576616c756518022001280b32102e666f6f2e546573744d657373" .
+ "6167653a0238011a100a0353756212090a0161180120012805420a0a086d" .
+ "795f6f6e656f6622b7030a11546573745061636b65644d65737361676512" .
+ "1a0a0e72657065617465645f696e743332185a2003280542021001121a0a" .
+ "0e72657065617465645f696e743634185b2003280342021001121b0a0f72" .
+ "657065617465645f75696e743332185c2003280d42021001121b0a0f7265" .
+ "7065617465645f75696e743634185d2003280442021001121b0a0f726570" .
+ "65617465645f73696e743332185e2003281142021001121b0a0f72657065" .
+ "617465645f73696e743634185f2003281242021001121c0a107265706561" .
+ "7465645f6669786564333218602003280742021001121c0a107265706561" .
+ "7465645f6669786564363418612003280642021001121d0a117265706561" .
+ "7465645f736669786564333218622003280f42021001121d0a1172657065" .
+ "617465645f736669786564363418632003281042021001121a0a0e726570" .
+ "65617465645f666c6f617418642003280242021001121b0a0f7265706561" .
+ "7465645f646f75626c651865200328014202100112190a0d726570656174" .
+ "65645f626f6f6c1866200328084202100112280a0d72657065617465645f" .
+ "656e756d18672003280e320d2e666f6f2e54657374456e756d4202100122" .
+ "b9030a1354657374556e7061636b65644d657373616765121a0a0e726570" .
+ "65617465645f696e743332185a2003280542021000121a0a0e7265706561" .
+ "7465645f696e743634185b2003280342021000121b0a0f72657065617465" .
+ "645f75696e743332185c2003280d42021000121b0a0f7265706561746564" .
+ "5f75696e743634185d2003280442021000121b0a0f72657065617465645f" .
+ "73696e743332185e2003281142021000121b0a0f72657065617465645f73" .
+ "696e743634185f2003281242021000121c0a1072657065617465645f6669" .
+ "786564333218602003280742021000121c0a1072657065617465645f6669" .
+ "786564363418612003280642021000121d0a1172657065617465645f7366" .
+ "69786564333218622003280f42021000121d0a1172657065617465645f73" .
+ "6669786564363418632003281042021000121a0a0e72657065617465645f" .
+ "666c6f617418642003280242021000121b0a0f72657065617465645f646f" .
+ "75626c651865200328014202100012190a0d72657065617465645f626f6f" .
+ "6c1866200328084202100012280a0d72657065617465645f656e756d1867" .
+ "2003280e320d2e666f6f2e54657374456e756d420210002a1d0a08546573" .
+ "74456e756d12080a045a45524f100012070a034f4e451001620670726f74" .
+ "6f33"
+));
+
diff --git a/php/tests/test.sh b/php/tests/test.sh
index f3f04a47..888e93eb 100755
--- a/php/tests/test.sh
+++ b/php/tests/test.sh
@@ -1,10 +1,5 @@
#!/bin/bash
-# Compile protoc
-pushd ../../
-./autogen.sh && ./configure && make
-popd
-
# Generate test file
../../src/protoc --php_out=. test.proto test_include.proto
diff --git a/php/tests/test_include.pb.php b/php/tests/test_include.pb.php
new file mode 100644
index 00000000..2c43cc41
--- /dev/null
+++ b/php/tests/test_include.pb.php
@@ -0,0 +1,36 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: test_include.proto
+
+namespace Bar;
+
+use Google\Protobuf\Internal\DescriptorPool;
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\GPBUtil;
+
+class TestInclude extends \Google\Protobuf\Internal\Message
+{
+ private $a = 0;
+
+ public function getA()
+ {
+ return $this->a;
+ }
+
+ public function setA($var)
+ {
+ GPBUtil::checkInt32($var);
+ $this->a = $var;
+ }
+
+}
+
+$pool = DescriptorPool::getGeneratedPool();
+
+$pool->internalAddGeneratedFile(hex2bin(
+ "0a3b0a12746573745f696e636c7564652e70726f746f120362617222180a" .
+ "0b54657374496e636c75646512090a0161180120012805620670726f746f" .
+ "33"
+));
+
diff --git a/php/tests/test_util.php b/php/tests/test_util.php
index decd1a78..2f6e4dd8 100644
--- a/php/tests/test_util.php
+++ b/php/tests/test_util.php
@@ -50,6 +50,8 @@ class TestUtil
public static function setTestMessage(TestMessage $m)
{
+ $sub = new TestMessage_Sub();
+
$m->setOptionalInt32(-42);
$m->setOptionalInt64(-43);
$m->setOptionalUint32(42);
@@ -66,7 +68,7 @@ class TestUtil
$m->setOptionalString('a');
$m->setOptionalBytes('b');
$m->setOptionalEnum(TestEnum::ONE);
- $m->setOptionalMessage(new TestMessage_Sub());
+ $m->setOptionalMessage($sub);
$m->getOptionalMessage()->SetA(33);
$m->getRepeatedInt32() []= -42;