setWriteVersion($override_version); if (function_exists('thrift_protocol_set_compact_version')) { $last_version = thrift_protocol_set_compact_version($override_version); } else { $use_hphp_extension = false; } } if ($use_hphp_extension) { thrift_protocol_write_compact( $protocol, $object->getName(), TMessageType::REPLY, $object, 0, ); if ($last_version !== null) { thrift_protocol_set_compact_version($last_version); } $unused_name = null; $unused_type = null; $unused_seqid = null; $protocol->readMessageBegin( inout $unused_name, inout $unused_type, inout $unused_seqid, ); } else { $object->write($protocol); } return $transport->getBuffer(); } public static function deserialize( string $str, T $object, ?int $override_version = null, bool $disable_hphp_extension = false, ) { $transport = new TMemoryBuffer(); $protocol = new TCompactProtocolAccelerated($transport); $use_hphp_extension = function_exists('thrift_protocol_read_compact') && !$disable_hphp_extension; if ($override_version !== null) { $protocol->setWriteVersion($override_version); if (!function_exists('thrift_protocol_set_compact_version')) { $use_hphp_extension = false; } } if ($use_hphp_extension) { $protocol->writeMessageBegin('', TMessageType::REPLY, 0); $transport->write($str); $object = thrift_protocol_read_compact($protocol, get_class($object)); } else { $transport->write($str); /* HH_FIXME[2060] Trust me, I know what I'm doing */ $object->read($protocol); } return $object; } }