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 ...@@ -81,41 +81,44 @@ class Message
switch ($value_field->getType()) { switch ($value_field->getType()) {
case GPBType::MESSAGE: case GPBType::MESSAGE:
case GPBType::GROUP: case GPBType::GROUP:
$this->$setter( $map_field = new MapField(
new MapField(
$key_field->getType(), $key_field->getType(),
$value_field->getType(), $value_field->getType(),
$value_field->getMessageType()->getClass())); $value_field->getMessageType()->getClass());
$this->$setter($map_field);
break; break;
case GPBType::ENUM: case GPBType::ENUM:
$this->$setter( $map_field = new MapField(
new MapField(
$key_field->getType(), $key_field->getType(),
$value_field->getType(), $value_field->getType(),
$value_field->getEnumType()->getClass())); $value_field->getEnumType()->getClass());
$this->$setter($map_field);
break; break;
default: default:
$this->$setter(new MapField($key_field->getType(), $map_field = new MapField(
$value_field->getType())); $key_field->getType(),
$value_field->getType());
$this->$setter($map_field);
break; break;
} }
} else if ($field->getLabel() === GPBLabel::REPEATED) { } else if ($field->getLabel() === GPBLabel::REPEATED) {
switch ($field->getType()) { switch ($field->getType()) {
case GPBType::MESSAGE: case GPBType::MESSAGE:
case GPBType::GROUP: case GPBType::GROUP:
$this->$setter( $repeated_field = new RepeatedField(
new RepeatedField(
$field->getType(), $field->getType(),
$field->getMessageType()->getClass())); $field->getMessageType()->getClass());
$this->$setter($repeated_field);
break; break;
case GPBType::ENUM: case GPBType::ENUM:
$this->$setter( $repeated_field = new RepeatedField(
new RepeatedField(
$field->getType(), $field->getType(),
$field->getEnumType()->getClass())); $field->getEnumType()->getClass());
$this->$setter($repeated_field);
break; break;
default: default:
$this->$setter(new RepeatedField($field->getType())); $repeated_field = new RepeatedField($field->getType());
$this->$setter($repeated_field);
break; break;
} }
} else if ($field->getOneofIndex() !== -1) { } else if ($field->getOneofIndex() !== -1) {
......
...@@ -50,6 +50,8 @@ class TestUtil ...@@ -50,6 +50,8 @@ class TestUtil
public static function setTestMessage(TestMessage $m) public static function setTestMessage(TestMessage $m)
{ {
$sub = new TestMessage_Sub();
$m->setOptionalInt32(-42); $m->setOptionalInt32(-42);
$m->setOptionalInt64(-43); $m->setOptionalInt64(-43);
$m->setOptionalUint32(42); $m->setOptionalUint32(42);
...@@ -66,7 +68,7 @@ class TestUtil ...@@ -66,7 +68,7 @@ class TestUtil
$m->setOptionalString('a'); $m->setOptionalString('a');
$m->setOptionalBytes('b'); $m->setOptionalBytes('b');
$m->setOptionalEnum(TestEnum::ONE); $m->setOptionalEnum(TestEnum::ONE);
$m->setOptionalMessage(new TestMessage_Sub()); $m->setOptionalMessage($sub);
$m->getOptionalMessage()->SetA(33); $m->getOptionalMessage()->SetA(33);
$m->getRepeatedInt32() []= -42; $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