Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
74f667dd
Unverified
Commit
74f667dd
authored
Jan 28, 2019
by
Paul Yang
Committed by
GitHub
Jan 28, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5644 from TeBoring/fix-4765
Convert integer to string if field is string field in json
parents
32339be9
8400e290
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
1 deletion
+16
-1
failure_list_php.txt
conformance/failure_list_php.txt
+2
-0
Message.php
php/src/Google/Protobuf/Internal/Message.php
+3
-0
encode_decode_test.php
php/tests/encode_decode_test.php
+10
-0
tests.sh
tests.sh
+1
-1
No files found.
conformance/failure_list_php.txt
View file @
74f667dd
...
...
@@ -13,6 +13,8 @@ Required.Proto3.JsonInput.FloatFieldTooSmall
Required.Proto3.JsonInput.DoubleFieldTooSmall
Required.Proto3.JsonInput.Int32FieldNotInteger
Required.Proto3.JsonInput.Int64FieldNotInteger
Required.Proto3.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt
Required.Proto3.JsonInput.StringFieldNotAString
Required.Proto3.JsonInput.Uint32FieldNotInteger
Required.Proto3.JsonInput.Uint64FieldNotInteger
Required.Proto3.JsonInput.Int32FieldLeadingSpace
...
...
php/src/Google/Protobuf/Internal/Message.php
View file @
74f667dd
...
...
@@ -832,6 +832,9 @@ class Message
if
(
is_null
(
$value
))
{
return
$this
->
defaultValue
(
$field
);
}
if
(
is_numeric
(
$value
))
{
return
strval
(
$value
);
}
if
(
!
is_string
(
$value
))
{
throw
new
GPBDecodeException
(
"String field only accepts string value"
);
...
...
php/tests/encode_decode_test.php
View file @
74f667dd
...
...
@@ -1148,4 +1148,14 @@ class EncodeDecodeTest extends TestBase
$m
->
serializeToJsonString
());
}
public
function
testJsonDecodeNumericStringMapKey
()
{
$m
=
new
TestMessage
();
$m
->
getMapStringString
()[
"1"
]
=
"1"
;
$data
=
$m
->
serializeToJsonString
();
$this
->
assertSame
(
"
{
\"mapStringString\":{\"1\":\"1\"}
}
"
,
$data
);
$n
=
new
TestMessage
();
$n
->
mergeFromJsonString
(
$data
);
}
}
tests.sh
View file @
74f667dd
...
...
@@ -482,7 +482,7 @@ build_php5.6_mac() {
export
PATH
=
"
$PHP_FOLDER
/bin:
$PATH
"
# Install phpunit
curl https://phar.phpunit.de/phpunit-5.6.
10
.phar
-L
-o
phpunit.phar
curl https://phar.phpunit.de/phpunit-5.6.
8
.phar
-L
-o
phpunit.phar
chmod
+x phpunit.phar
sudo mv
phpunit.phar /usr/local/bin/phpunit
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment