public function read($input) { $xfer = 0; $fname = null; $ftype = 0; $fid = 0; $xfer += $input->readStructBegin($fname); while (true) { $xfer += $input->readFieldBegin($fname, $ftype, $fid); if ($ftype == TType::STOP) { break; } switch ($fid) { case 1: if ($ftype == TType::LST) { $this->bonk = array(); $_size244 = 0; $_etype247 = 0; $xfer += $input->readListBegin($_etype247, $_size244); for ($_i248 = 0; $_i248 < $_size244; ++$_i248) { $elem249 = null; $elem249 = array(); $_size250 = 0; $_etype253 = 0; $xfer += $input->readListBegin($_etype253, $_size250); for ($_i254 = 0; $_i254 < $_size250; ++$_i254) { $elem255 = null; $elem255 = array(); $_size256 = 0; $_etype259 = 0; $xfer += $input->readListBegin($_etype259, $_size256); for ($_i260 = 0; $_i260 < $_size256; ++$_i260) { $elem261 = null; $elem261 = new \ThriftTest\Bonk(); $xfer += $elem261->read($input); $elem255[] = $elem261; } $xfer += $input->readListEnd(); $elem249[] = $elem255; } $xfer += $input->readListEnd(); $this->bonk[] = $elem249; } $xfer += $input->readListEnd(); } else { $xfer += $input->skip($ftype); } break; default: $xfer += $input->skip($ftype); break; } $xfer += $input->readFieldEnd(); } $xfer += $input->readStructEnd(); return $xfer; }
}); set_error_handler(function ($errno, $errmsg) { my_assert(false, "Unexpected PHP error: " . $errmsg); }); // Empty structs should not have validators assert_has_no_read_validator('ThriftTest\\EmptyStruct'); assert_has_no_write_validator('ThriftTest\\EmptyStruct'); assert_has_no_read_validator('ThriftTest\\Bonk'); assert_has_a_write_validator('ThriftTest\\Bonk'); // Check that we can read an empty object $bonk = new \ThriftTest\Bonk(); $transport = new TMemoryBuffer(""); $protocol = new TBinaryProtocol($transport); $bonk->read($protocol); // ...but not write an empty object $bonk = new \ThriftTest\Bonk(); $transport = new TMemoryBuffer(); $protocol = new TBinaryProtocol($transport); assert_protocol_exception_thrown(function () use($bonk, $protocol) { $bonk->write($protocol); }, 'Bonk was able to write an empty object'); assert_has_a_read_validator('ThriftTest\\StructA'); assert_has_a_write_validator('ThriftTest\\StructA'); // Check that we are not able to write StructA with a missing required field $structa = new \ThriftTest\StructA(); $transport = new TMemoryBuffer(); $protocol = new TBinaryProtocol($transport); assert_protocol_exception_thrown(function () use($structa, $protocol) { $structa->write($protocol); }, 'StructA was able to write an empty object'); // Check that we are able to read and write a message with a good StructA