diff --git a/conformance/failure_list_php_c.txt b/conformance/failure_list_php_c.txt index eaa1b612d9..e25629deeb 100644 --- a/conformance/failure_list_php_c.txt +++ b/conformance/failure_list_php_c.txt @@ -58,8 +58,6 @@ Required.Proto3.JsonInput.FloatFieldInfinity.JsonOutput Required.Proto3.JsonInput.FloatFieldNan.JsonOutput Required.Proto3.JsonInput.FloatFieldNegativeInfinity.JsonOutput Required.Proto3.JsonInput.OneofFieldDuplicate -Required.Proto3.JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput -Required.Proto3.JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput Required.Proto3.JsonInput.RejectTopLevelNull Required.Proto3.JsonInput.StringFieldSurrogatePair.JsonOutput Required.Proto3.JsonInput.StringFieldSurrogatePair.ProtobufOutput diff --git a/php/ext/google/protobuf/upb.c b/php/ext/google/protobuf/upb.c index cc5a54ab84..3484b74779 100644 --- a/php/ext/google/protobuf/upb.c +++ b/php/ext/google/protobuf/upb.c @@ -9964,7 +9964,8 @@ static bool start_any_stringval(upb_json_parser *p) { static bool start_stringval(upb_json_parser *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); } else if (is_wellknown_msg(p, UPB_WELLKNOWN_FIELDMASK)) { start_fieldmask_object(p); @@ -9977,7 +9978,8 @@ static bool start_stringval(upb_json_parser *p) { } else { 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)) { return false; } @@ -10183,7 +10185,8 @@ static bool end_stringval(upb_json_parser *p) { return false; } - if (does_string_wrapper_end(p)) { + if (does_string_wrapper_end(p) || + does_number_wrapper_end(p)) { end_wrapper_object(p); if (!is_top_level(p)) { end_subobject(p); diff --git a/php/tests/encode_decode_test.php b/php/tests/encode_decode_test.php index 5b373bb07e..f2a50180c6 100644 --- a/php/tests/encode_decode_test.php +++ b/php/tests/encode_decode_test.php @@ -118,12 +118,19 @@ class EncodeDecodeTest extends TestBase $this->assertEquals(1, $m->getValue()); } - # public function testEncodeTopLevelInt64Value() - # { - # $m = new Int64Value(); - # $m->setValue(1); - # $this->assertSame("\"1\"", $m->serializeToJsonString()); - # } + public function testDecodeTopLevelInt64ValueAsString() + { + $m = new Int64Value(); + $m->mergeFromJsonString("\"1\""); + $this->assertEquals(1, $m->getValue()); + } + + public function testEncodeTopLevelInt64Value() + { + $m = new Int64Value(); + $m->setValue(1); + $this->assertSame("\"1\"", $m->serializeToJsonString()); + } public function testDecodeTopLevelUInt64Value() { @@ -132,12 +139,19 @@ class EncodeDecodeTest extends TestBase $this->assertEquals(1, $m->getValue()); } - # public function testEncodeTopLevelUInt64Value() - # { - # $m = new UInt64Value(); - # $m->setValue(1); - # $this->assertSame("\"1\"", $m->serializeToJsonString()); - # } + public function testDecodeTopLevelUInt64ValueAsString() + { + $m = new UInt64Value(); + $m->mergeFromJsonString("\"1\""); + $this->assertEquals(1, $m->getValue()); + } + + public function testEncodeTopLevelUInt64Value() + { + $m = new UInt64Value(); + $m->setValue(1); + $this->assertSame("\"1\"", $m->serializeToJsonString()); + } public function testDecodeTopLevelStringValue() {