Commit 9372292b authored by Stanley Cheung's avatar Stanley Cheung Committed by Bo Yang

PHP: support 7.0 on PHP implementation (#2162)

* PHP: support 7.0

* Also fix in test_util.php
parent f933d10f
......@@ -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) {
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment