Skip to content
Snippets Groups Projects
Commit 20a06a05 authored by Stanley Cheung's avatar Stanley Cheung Committed by GitHub
Browse files

Merge pull request #10134 from stanley-cheung/php-proto3-api-change

PHP: proto3 api change
parents 767adee1 55bff483
No related branches found
No related tags found
No related merge requests found
...@@ -131,6 +131,8 @@ abstract class AbstractCall ...@@ -131,6 +131,8 @@ abstract class AbstractCall
// Proto3 implementation // Proto3 implementation
if (method_exists($data, 'encode')) { if (method_exists($data, 'encode')) {
return $data->encode(); return $data->encode();
} else if (method_exists($data, 'serializeToString')) {
return $data->serializeToString();
} }
// Protobuf-PHP implementation // Protobuf-PHP implementation
...@@ -154,7 +156,11 @@ abstract class AbstractCall ...@@ -154,7 +156,11 @@ abstract class AbstractCall
if (is_array($this->deserialize)) { if (is_array($this->deserialize)) {
list($className, $deserializeFunc) = $this->deserialize; list($className, $deserializeFunc) = $this->deserialize;
$obj = new $className(); $obj = new $className();
$obj->$deserializeFunc($value); if (method_exists($obj, $deserializeFunc)) {
$obj->$deserializeFunc($value);
} else {
$obj->mergeFromString($value);
}
return $obj; return $obj;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment