public function write(TProtocol $output) { $xfer = 0; $xfer += $output->writeStructBegin('Person'); if ($this->id !== null) { $xfer += $output->writeFieldBegin('id', TType::I64, 1); $xfer += $output->writeI64($this->id); $xfer += $output->writeFieldEnd(); } if ($this->name !== null) { $xfer += $output->writeFieldBegin('name', TType::STRING, 2); $xfer += $output->writeString($this->name); $xfer += $output->writeFieldEnd(); } if (isset($this->age) && $this->age !== null) { $xfer += $output->writeFieldBegin('age', TType::I16, 3); $xfer += $output->writeI16($this->age); $xfer += $output->writeFieldEnd(); } if (isset($this->address) && $this->address !== null) { $xfer += $output->writeFieldBegin('address', TType::STRING, 4); $xfer += $output->writeString($this->address); $xfer += $output->writeFieldEnd(); } if (isset($this->favoriteColor) && $this->favoriteColor !== null) { if (!is_object($this->favoriteColor)) { throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); } $xfer += $output->writeFieldBegin('favoriteColor', TType::STRUCT, 5); $xfer += $this->favoriteColor->write($output); $xfer += $output->writeFieldEnd(); } if (isset($this->friends) && $this->friends !== null) { if (!is_array($this->friends) && !(($this->friends instanceof Iterator || $this->friends instanceof IteratorAggregate) && $this->friends instanceof Countable)) { throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); } $xfer += $output->writeFieldBegin('friends', TType::SET, 6); $output->writeSetBegin(TType::I64, count($this->friends)); foreach ($this->friends as $iter0 => $true) { $xfer += $output->writeI64($iter0); } $output->writeSetEnd(); $xfer += $output->writeFieldEnd(); } if (isset($this->bestFriend) && $this->bestFriend !== null) { $xfer += $output->writeFieldBegin('bestFriend', TType::I64, 7); $xfer += $output->writeI64($this->bestFriend); $xfer += $output->writeFieldEnd(); } if (isset($this->petNames) && $this->petNames !== null) { if (!is_array($this->petNames) && !(($this->petNames instanceof Iterator || $this->petNames instanceof IteratorAggregate) && $this->petNames instanceof Countable)) { throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); } $xfer += $output->writeFieldBegin('petNames', TType::MAP, 8); $output->writeMapBegin(TType::I32, TType::STRING, count($this->petNames)); foreach ($this->petNames as $kiter1 => $viter2) { $xfer += $output->writeI32($kiter1); $xfer += $output->writeString($viter2); } $output->writeMapEnd(); $xfer += $output->writeFieldEnd(); } if (isset($this->afraidOfAnimal) && $this->afraidOfAnimal !== null) { $xfer += $output->writeFieldBegin('afraidOfAnimal', TType::I32, 9); $xfer += $output->writeI32($this->afraidOfAnimal); $xfer += $output->writeFieldEnd(); } if (isset($this->vehicles) && $this->vehicles !== null) { if (!is_array($this->vehicles) && !(($this->vehicles instanceof Iterator || $this->vehicles instanceof IteratorAggregate) && $this->vehicles instanceof Countable)) { throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); } $xfer += $output->writeFieldBegin('vehicles', TType::LST, 10); $output->writeListBegin(TType::STRUCT, count($this->vehicles)); foreach ($this->vehicles as $iter3) { $xfer += $iter3->write($output); } $output->writeListEnd(); $xfer += $output->writeFieldEnd(); } $xfer += $output->writeFieldStop(); $xfer += $output->writeStructEnd(); return $xfer; }