Accept string for int64 wrappers (#6491)

pull/6542/head
Paul Yang 5 years ago committed by GitHub
parent ee4f2492ea
commit 6b3024f693
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      conformance/failure_list_php_c.txt
  2. 9
      php/ext/google/protobuf/upb.c
  3. 38
      php/tests/encode_decode_test.php

@ -58,8 +58,6 @@ Required.Proto3.JsonInput.FloatFieldInfinity.JsonOutput
Required.Proto3.JsonInput.FloatFieldNan.JsonOutput Required.Proto3.JsonInput.FloatFieldNan.JsonOutput
Required.Proto3.JsonInput.FloatFieldNegativeInfinity.JsonOutput Required.Proto3.JsonInput.FloatFieldNegativeInfinity.JsonOutput
Required.Proto3.JsonInput.OneofFieldDuplicate Required.Proto3.JsonInput.OneofFieldDuplicate
Required.Proto3.JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput
Required.Proto3.JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput
Required.Proto3.JsonInput.RejectTopLevelNull Required.Proto3.JsonInput.RejectTopLevelNull
Required.Proto3.JsonInput.StringFieldSurrogatePair.JsonOutput Required.Proto3.JsonInput.StringFieldSurrogatePair.JsonOutput
Required.Proto3.JsonInput.StringFieldSurrogatePair.ProtobufOutput Required.Proto3.JsonInput.StringFieldSurrogatePair.ProtobufOutput

@ -9964,7 +9964,8 @@ static bool start_any_stringval(upb_json_parser *p) {
static bool start_stringval(upb_json_parser *p) { static bool start_stringval(upb_json_parser *p) {
if (is_top_level(p)) { if (is_top_level(p)) {
if (is_string_wrapper_object(p)) { if (is_string_wrapper_object(p) ||
is_number_wrapper_object(p)) {
start_wrapper_object(p); start_wrapper_object(p);
} else if (is_wellknown_msg(p, UPB_WELLKNOWN_FIELDMASK)) { } else if (is_wellknown_msg(p, UPB_WELLKNOWN_FIELDMASK)) {
start_fieldmask_object(p); start_fieldmask_object(p);
@ -9977,7 +9978,8 @@ static bool start_stringval(upb_json_parser *p) {
} else { } else {
return false; return false;
} }
} else if (does_string_wrapper_start(p)) { } else if (does_string_wrapper_start(p) ||
does_number_wrapper_start(p)) {
if (!start_subobject(p)) { if (!start_subobject(p)) {
return false; return false;
} }
@ -10183,7 +10185,8 @@ static bool end_stringval(upb_json_parser *p) {
return false; return false;
} }
if (does_string_wrapper_end(p)) { if (does_string_wrapper_end(p) ||
does_number_wrapper_end(p)) {
end_wrapper_object(p); end_wrapper_object(p);
if (!is_top_level(p)) { if (!is_top_level(p)) {
end_subobject(p); end_subobject(p);

@ -118,12 +118,19 @@ class EncodeDecodeTest extends TestBase
$this->assertEquals(1, $m->getValue()); $this->assertEquals(1, $m->getValue());
} }
# public function testEncodeTopLevelInt64Value() public function testDecodeTopLevelInt64ValueAsString()
# { {
# $m = new Int64Value(); $m = new Int64Value();
# $m->setValue(1); $m->mergeFromJsonString("\"1\"");
# $this->assertSame("\"1\"", $m->serializeToJsonString()); $this->assertEquals(1, $m->getValue());
# } }
public function testEncodeTopLevelInt64Value()
{
$m = new Int64Value();
$m->setValue(1);
$this->assertSame("\"1\"", $m->serializeToJsonString());
}
public function testDecodeTopLevelUInt64Value() public function testDecodeTopLevelUInt64Value()
{ {
@ -132,12 +139,19 @@ class EncodeDecodeTest extends TestBase
$this->assertEquals(1, $m->getValue()); $this->assertEquals(1, $m->getValue());
} }
# public function testEncodeTopLevelUInt64Value() public function testDecodeTopLevelUInt64ValueAsString()
# { {
# $m = new UInt64Value(); $m = new UInt64Value();
# $m->setValue(1); $m->mergeFromJsonString("\"1\"");
# $this->assertSame("\"1\"", $m->serializeToJsonString()); $this->assertEquals(1, $m->getValue());
# } }
public function testEncodeTopLevelUInt64Value()
{
$m = new UInt64Value();
$m->setValue(1);
$this->assertSame("\"1\"", $m->serializeToJsonString());
}
public function testDecodeTopLevelStringValue() public function testDecodeTopLevelStringValue()
{ {

Loading…
Cancel
Save