Merge pull request #23020 from jeffreyqw/remove-deserializefunc

PHP: AbstractCall remove decode method
pull/23089/head
Stanley Cheung 5 years ago committed by GitHub
commit 7889bc9e55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 19
      src/php/lib/Grpc/AbstractCall.php

@ -114,16 +114,9 @@ abstract class AbstractCall
protected function _serializeMessage($data) protected function _serializeMessage($data)
{ {
// Proto3 implementation // Proto3 implementation
if (method_exists($data, 'encode')) {
return $data->encode();
} elseif (method_exists($data, 'serializeToString')) {
return $data->serializeToString(); return $data->serializeToString();
} }
// Protobuf-PHP implementation
return $data->serialize();
}
/** /**
* Deserialize a response value to an object. * Deserialize a response value to an object.
* *
@ -136,24 +129,12 @@ abstract class AbstractCall
if ($value === null) { if ($value === null) {
return; return;
} }
// Proto3 implementation
if (is_array($this->deserialize)) {
list($className, $deserializeFunc) = $this->deserialize; list($className, $deserializeFunc) = $this->deserialize;
$obj = new $className(); $obj = new $className();
if (method_exists($obj, $deserializeFunc)) {
$obj->$deserializeFunc($value);
} else {
$obj->mergeFromString($value); $obj->mergeFromString($value);
}
return $obj; return $obj;
} }
// Protobuf-PHP implementation
return call_user_func($this->deserialize, $value);
}
/** /**
* Set the CallCredentials for the underlying Call. * Set the CallCredentials for the underlying Call.
* *

Loading…
Cancel
Save