/** * Creates \Skrz\Meta\Fixtures\Protobuf\ClassWithFixed64Property object from serialized Protocol Buffers message. * * @param string $input * @param ClassWithFixed64Property $object * @param int $start * @param int $end * * @throws \Exception * * @return ClassWithFixed64Property */ public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL) { if ($object === null) { $object = new ClassWithFixed64Property(); } if ($end === null) { $end = strlen($input); } while ($start < $end) { $tag = Binary::decodeVarint($input, $start); $wireType = $tag & 0x7; $number = $tag >> 3; switch ($number) { case 1: if ($wireType !== 1) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 1.', $number); } $expectedStart = $start + 8; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->x = Binary::decodeUint64($input, $start); if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; default: switch ($wireType) { case 0: Binary::decodeVarint($input, $start); break; case 1: $start += 8; break; case 2: $start += Binary::decodeVarint($input, $start); break; case 5: $start += 4; break; default: throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number); } } } return $object; }