MCPcopy Create free account
hub / github.com/apache/thrift / _read

Method _read

lib/php/src/Thrift.php:221–270  ·  view source on GitHub ↗
($class, $spec, $input)

Source from the content-addressed store, hash-verified

219 }
220
221 protected function _read($class, $spec, $input)
222 {
223 $xfer = 0;
224 $fname = null;
225 $ftype = 0;
226 $fid = 0;
227 $xfer += $input->readStructBegin($fname);
228 while (true) {
229 $xfer += $input->readFieldBegin($fname, $ftype, $fid);
230 if ($ftype == TType::STOP) {
231 break;
232 }
233 if (isset($spec[$fid])) {
234 $fspec = $spec[$fid];
235 $var = $fspec['var'];
236 if ($ftype == $fspec['type']) {
237 $xfer = 0;
238 if (isset(TBase::$tmethod[$ftype])) {
239 $func = 'read'.TBase::$tmethod[$ftype];
240 $xfer += $input->$func($this->$var);
241 } else {
242 switch ($ftype) {
243 case TType::STRUCT:
244 $class = $fspec['class'];
245 $this->$var = new $class();
246 $xfer += $this->$var->read($input);
247 break;
248 case TType::MAP:
249 $xfer += $this->_readMap($this->$var, $fspec, $input);
250 break;
251 case TType::LST:
252 $xfer += $this->_readList($this->$var, $fspec, $input, false);
253 break;
254 case TType::SET:
255 $xfer += $this->_readList($this->$var, $fspec, $input, true);
256 break;
257 }
258 }
259 } else {
260 $xfer += $input->skip($ftype);
261 }
262 } else {
263 $xfer += $input->skip($ftype);
264 }
265 $xfer += $input->readFieldEnd();
266 }
267 $xfer += $input->readStructEnd();
268
269 return $xfer;
270 }
271
272 private function _writeMap($var, $spec, $output)
273 {

Callers

nothing calls this directly

Calls 8

_readMapMethod · 0.95
_readListMethod · 0.95
readStructBeginMethod · 0.65
readFieldBeginMethod · 0.65
readMethod · 0.65
readFieldEndMethod · 0.65
readStructEndMethod · 0.65
skipMethod · 0.45

Tested by

no test coverage detected