Commit f8ca3acd authored by Paul Yang's avatar Paul Yang Committed by GitHub

Generate phpdoc in php generated files. (#2406)

parent 851cb81d
...@@ -10,834 +10,1458 @@ use Google\Protobuf\Internal\GPBType; ...@@ -10,834 +10,1458 @@ use Google\Protobuf\Internal\GPBType;
use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil; use Google\Protobuf\Internal\GPBUtil;
/**
* Protobuf type <code>foo.TestMessage</code>
*/
class TestMessage extends \Google\Protobuf\Internal\Message class TestMessage extends \Google\Protobuf\Internal\Message
{ {
/**
* <pre>
* Singular
* </pre>
*
* <code>optional int32 optional_int32 = 1;</code>
*/
private $optional_int32 = 0; private $optional_int32 = 0;
/**
* <code>optional int64 optional_int64 = 2;</code>
*/
private $optional_int64 = 0; private $optional_int64 = 0;
/**
* <code>optional uint32 optional_uint32 = 3;</code>
*/
private $optional_uint32 = 0; private $optional_uint32 = 0;
/**
* <code>optional uint64 optional_uint64 = 4;</code>
*/
private $optional_uint64 = 0; private $optional_uint64 = 0;
/**
* <code>optional sint32 optional_sint32 = 5;</code>
*/
private $optional_sint32 = 0; private $optional_sint32 = 0;
/**
* <code>optional sint64 optional_sint64 = 6;</code>
*/
private $optional_sint64 = 0; private $optional_sint64 = 0;
/**
* <code>optional fixed32 optional_fixed32 = 7;</code>
*/
private $optional_fixed32 = 0; private $optional_fixed32 = 0;
/**
* <code>optional fixed64 optional_fixed64 = 8;</code>
*/
private $optional_fixed64 = 0; private $optional_fixed64 = 0;
/**
* <code>optional sfixed32 optional_sfixed32 = 9;</code>
*/
private $optional_sfixed32 = 0; private $optional_sfixed32 = 0;
/**
* <code>optional sfixed64 optional_sfixed64 = 10;</code>
*/
private $optional_sfixed64 = 0; private $optional_sfixed64 = 0;
/**
* <code>optional float optional_float = 11;</code>
*/
private $optional_float = 0.0; private $optional_float = 0.0;
/**
* <code>optional double optional_double = 12;</code>
*/
private $optional_double = 0.0; private $optional_double = 0.0;
/**
* <code>optional bool optional_bool = 13;</code>
*/
private $optional_bool = false; private $optional_bool = false;
/**
* <code>optional string optional_string = 14;</code>
*/
private $optional_string = ''; private $optional_string = '';
/**
* <code>optional bytes optional_bytes = 15;</code>
*/
private $optional_bytes = ''; private $optional_bytes = '';
/**
* <code>optional .foo.TestEnum optional_enum = 16;</code>
*/
private $optional_enum = 0; private $optional_enum = 0;
/**
* <code>optional .foo.TestMessage.Sub optional_message = 17;</code>
*/
private $optional_message = null; private $optional_message = null;
/**
* <code>optional .bar.TestInclude optional_included_message = 18;</code>
*/
private $optional_included_message = null; private $optional_included_message = null;
/**
* <code>optional .foo.TestMessage recursive = 19;</code>
*/
private $recursive = null; private $recursive = null;
/**
* <pre>
* Repeated
* </pre>
*
* <code>repeated int32 repeated_int32 = 31;</code>
*/
private $repeated_int32; private $repeated_int32;
/**
* <code>repeated int64 repeated_int64 = 32;</code>
*/
private $repeated_int64; private $repeated_int64;
/**
* <code>repeated uint32 repeated_uint32 = 33;</code>
*/
private $repeated_uint32; private $repeated_uint32;
/**
* <code>repeated uint64 repeated_uint64 = 34;</code>
*/
private $repeated_uint64; private $repeated_uint64;
/**
* <code>repeated sint32 repeated_sint32 = 35;</code>
*/
private $repeated_sint32; private $repeated_sint32;
/**
* <code>repeated sint64 repeated_sint64 = 36;</code>
*/
private $repeated_sint64; private $repeated_sint64;
/**
* <code>repeated fixed32 repeated_fixed32 = 37;</code>
*/
private $repeated_fixed32; private $repeated_fixed32;
/**
* <code>repeated fixed64 repeated_fixed64 = 38;</code>
*/
private $repeated_fixed64; private $repeated_fixed64;
/**
* <code>repeated sfixed32 repeated_sfixed32 = 39;</code>
*/
private $repeated_sfixed32; private $repeated_sfixed32;
/**
* <code>repeated sfixed64 repeated_sfixed64 = 40;</code>
*/
private $repeated_sfixed64; private $repeated_sfixed64;
/**
* <code>repeated float repeated_float = 41;</code>
*/
private $repeated_float; private $repeated_float;
/**
* <code>repeated double repeated_double = 42;</code>
*/
private $repeated_double; private $repeated_double;
/**
* <code>repeated bool repeated_bool = 43;</code>
*/
private $repeated_bool; private $repeated_bool;
/**
* <code>repeated string repeated_string = 44;</code>
*/
private $repeated_string; private $repeated_string;
/**
* <code>repeated bytes repeated_bytes = 45;</code>
*/
private $repeated_bytes; private $repeated_bytes;
/**
* <code>repeated .foo.TestEnum repeated_enum = 46;</code>
*/
private $repeated_enum; private $repeated_enum;
/**
* <code>repeated .foo.TestMessage.Sub repeated_message = 47;</code>
*/
private $repeated_message; private $repeated_message;
/**
* <code>repeated .foo.TestMessage repeated_recursive = 48;</code>
*/
private $repeated_recursive; private $repeated_recursive;
/**
* <code>map&lt;int32, int32&gt; map_int32_int32 = 71;</code>
*/
private $map_int32_int32; private $map_int32_int32;
/**
* <code>map&lt;int64, int64&gt; map_int64_int64 = 72;</code>
*/
private $map_int64_int64; private $map_int64_int64;
/**
* <code>map&lt;uint32, uint32&gt; map_uint32_uint32 = 73;</code>
*/
private $map_uint32_uint32; private $map_uint32_uint32;
/**
* <code>map&lt;uint64, uint64&gt; map_uint64_uint64 = 74;</code>
*/
private $map_uint64_uint64; private $map_uint64_uint64;
/**
* <code>map&lt;sint32, sint32&gt; map_sint32_sint32 = 75;</code>
*/
private $map_sint32_sint32; private $map_sint32_sint32;
/**
* <code>map&lt;sint64, sint64&gt; map_sint64_sint64 = 76;</code>
*/
private $map_sint64_sint64; private $map_sint64_sint64;
/**
* <code>map&lt;fixed32, fixed32&gt; map_fixed32_fixed32 = 77;</code>
*/
private $map_fixed32_fixed32; private $map_fixed32_fixed32;
/**
* <code>map&lt;fixed64, fixed64&gt; map_fixed64_fixed64 = 78;</code>
*/
private $map_fixed64_fixed64; private $map_fixed64_fixed64;
/**
* <code>map&lt;sfixed32, sfixed32&gt; map_sfixed32_sfixed32 = 79;</code>
*/
private $map_sfixed32_sfixed32; private $map_sfixed32_sfixed32;
/**
* <code>map&lt;sfixed64, sfixed64&gt; map_sfixed64_sfixed64 = 80;</code>
*/
private $map_sfixed64_sfixed64; private $map_sfixed64_sfixed64;
/**
* <code>map&lt;int32, float&gt; map_int32_float = 81;</code>
*/
private $map_int32_float; private $map_int32_float;
/**
* <code>map&lt;int32, double&gt; map_int32_double = 82;</code>
*/
private $map_int32_double; private $map_int32_double;
/**
* <code>map&lt;bool, bool&gt; map_bool_bool = 83;</code>
*/
private $map_bool_bool; private $map_bool_bool;
/**
* <code>map&lt;string, string&gt; map_string_string = 84;</code>
*/
private $map_string_string; private $map_string_string;
/**
* <code>map&lt;int32, bytes&gt; map_int32_bytes = 85;</code>
*/
private $map_int32_bytes; private $map_int32_bytes;
/**
* <code>map&lt;int32, .foo.TestEnum&gt; map_int32_enum = 86;</code>
*/
private $map_int32_enum; private $map_int32_enum;
/**
* <code>map&lt;int32, .foo.TestMessage.Sub&gt; map_int32_message = 87;</code>
*/
private $map_int32_message; private $map_int32_message;
/**
* <code>map&lt;int32, .foo.TestMessage&gt; map_recursive = 88;</code>
*/
private $map_recursive; private $map_recursive;
protected $my_oneof; protected $my_oneof;
/**
* <pre>
* Singular
* </pre>
*
* <code>optional int32 optional_int32 = 1;</code>
*/
public function getOptionalInt32() public function getOptionalInt32()
{ {
return $this->optional_int32; return $this->optional_int32;
} }
/**
* <pre>
* Singular
* </pre>
*
* <code>optional int32 optional_int32 = 1;</code>
*/
public function setOptionalInt32($var) public function setOptionalInt32($var)
{ {
GPBUtil::checkInt32($var); GPBUtil::checkInt32($var);
$this->optional_int32 = $var; $this->optional_int32 = $var;
} }
/**
* <code>optional int64 optional_int64 = 2;</code>
*/
public function getOptionalInt64() public function getOptionalInt64()
{ {
return $this->optional_int64; return $this->optional_int64;
} }
/**
* <code>optional int64 optional_int64 = 2;</code>
*/
public function setOptionalInt64($var) public function setOptionalInt64($var)
{ {
GPBUtil::checkInt64($var); GPBUtil::checkInt64($var);
$this->optional_int64 = $var; $this->optional_int64 = $var;
} }
/**
* <code>optional uint32 optional_uint32 = 3;</code>
*/
public function getOptionalUint32() public function getOptionalUint32()
{ {
return $this->optional_uint32; return $this->optional_uint32;
} }
/**
* <code>optional uint32 optional_uint32 = 3;</code>
*/
public function setOptionalUint32($var) public function setOptionalUint32($var)
{ {
GPBUtil::checkUint32($var); GPBUtil::checkUint32($var);
$this->optional_uint32 = $var; $this->optional_uint32 = $var;
} }
/**
* <code>optional uint64 optional_uint64 = 4;</code>
*/
public function getOptionalUint64() public function getOptionalUint64()
{ {
return $this->optional_uint64; return $this->optional_uint64;
} }
/**
* <code>optional uint64 optional_uint64 = 4;</code>
*/
public function setOptionalUint64($var) public function setOptionalUint64($var)
{ {
GPBUtil::checkUint64($var); GPBUtil::checkUint64($var);
$this->optional_uint64 = $var; $this->optional_uint64 = $var;
} }
/**
* <code>optional sint32 optional_sint32 = 5;</code>
*/
public function getOptionalSint32() public function getOptionalSint32()
{ {
return $this->optional_sint32; return $this->optional_sint32;
} }
/**
* <code>optional sint32 optional_sint32 = 5;</code>
*/
public function setOptionalSint32($var) public function setOptionalSint32($var)
{ {
GPBUtil::checkInt32($var); GPBUtil::checkInt32($var);
$this->optional_sint32 = $var; $this->optional_sint32 = $var;
} }
/**
* <code>optional sint64 optional_sint64 = 6;</code>
*/
public function getOptionalSint64() public function getOptionalSint64()
{ {
return $this->optional_sint64; return $this->optional_sint64;
} }
/**
* <code>optional sint64 optional_sint64 = 6;</code>
*/
public function setOptionalSint64($var) public function setOptionalSint64($var)
{ {
GPBUtil::checkInt64($var); GPBUtil::checkInt64($var);
$this->optional_sint64 = $var; $this->optional_sint64 = $var;
} }
/**
* <code>optional fixed32 optional_fixed32 = 7;</code>
*/
public function getOptionalFixed32() public function getOptionalFixed32()
{ {
return $this->optional_fixed32; return $this->optional_fixed32;
} }
/**
* <code>optional fixed32 optional_fixed32 = 7;</code>
*/
public function setOptionalFixed32($var) public function setOptionalFixed32($var)
{ {
GPBUtil::checkUint32($var); GPBUtil::checkUint32($var);
$this->optional_fixed32 = $var; $this->optional_fixed32 = $var;
} }
/**
* <code>optional fixed64 optional_fixed64 = 8;</code>
*/
public function getOptionalFixed64() public function getOptionalFixed64()
{ {
return $this->optional_fixed64; return $this->optional_fixed64;
} }
/**
* <code>optional fixed64 optional_fixed64 = 8;</code>
*/
public function setOptionalFixed64($var) public function setOptionalFixed64($var)
{ {
GPBUtil::checkUint64($var); GPBUtil::checkUint64($var);
$this->optional_fixed64 = $var; $this->optional_fixed64 = $var;
} }
/**
* <code>optional sfixed32 optional_sfixed32 = 9;</code>
*/
public function getOptionalSfixed32() public function getOptionalSfixed32()
{ {
return $this->optional_sfixed32; return $this->optional_sfixed32;
} }
/**
* <code>optional sfixed32 optional_sfixed32 = 9;</code>
*/
public function setOptionalSfixed32($var) public function setOptionalSfixed32($var)
{ {
GPBUtil::checkInt32($var); GPBUtil::checkInt32($var);
$this->optional_sfixed32 = $var; $this->optional_sfixed32 = $var;
} }
/**
* <code>optional sfixed64 optional_sfixed64 = 10;</code>
*/
public function getOptionalSfixed64() public function getOptionalSfixed64()
{ {
return $this->optional_sfixed64; return $this->optional_sfixed64;
} }
/**
* <code>optional sfixed64 optional_sfixed64 = 10;</code>
*/
public function setOptionalSfixed64($var) public function setOptionalSfixed64($var)
{ {
GPBUtil::checkInt64($var); GPBUtil::checkInt64($var);
$this->optional_sfixed64 = $var; $this->optional_sfixed64 = $var;
} }
/**
* <code>optional float optional_float = 11;</code>
*/
public function getOptionalFloat() public function getOptionalFloat()
{ {
return $this->optional_float; return $this->optional_float;
} }
/**
* <code>optional float optional_float = 11;</code>
*/
public function setOptionalFloat($var) public function setOptionalFloat($var)
{ {
GPBUtil::checkFloat($var); GPBUtil::checkFloat($var);
$this->optional_float = $var; $this->optional_float = $var;
} }
/**
* <code>optional double optional_double = 12;</code>
*/
public function getOptionalDouble() public function getOptionalDouble()
{ {
return $this->optional_double; return $this->optional_double;
} }
/**
* <code>optional double optional_double = 12;</code>
*/
public function setOptionalDouble($var) public function setOptionalDouble($var)
{ {
GPBUtil::checkDouble($var); GPBUtil::checkDouble($var);
$this->optional_double = $var; $this->optional_double = $var;
} }
/**
* <code>optional bool optional_bool = 13;</code>
*/
public function getOptionalBool() public function getOptionalBool()
{ {
return $this->optional_bool; return $this->optional_bool;
} }
/**
* <code>optional bool optional_bool = 13;</code>
*/
public function setOptionalBool($var) public function setOptionalBool($var)
{ {
GPBUtil::checkBool($var); GPBUtil::checkBool($var);
$this->optional_bool = $var; $this->optional_bool = $var;
} }
/**
* <code>optional string optional_string = 14;</code>
*/
public function getOptionalString() public function getOptionalString()
{ {
return $this->optional_string; return $this->optional_string;
} }
/**
* <code>optional string optional_string = 14;</code>
*/
public function setOptionalString($var) public function setOptionalString($var)
{ {
GPBUtil::checkString($var, True); GPBUtil::checkString($var, True);
$this->optional_string = $var; $this->optional_string = $var;
} }
/**
* <code>optional bytes optional_bytes = 15;</code>
*/
public function getOptionalBytes() public function getOptionalBytes()
{ {
return $this->optional_bytes; return $this->optional_bytes;
} }
/**
* <code>optional bytes optional_bytes = 15;</code>
*/
public function setOptionalBytes($var) public function setOptionalBytes($var)
{ {
GPBUtil::checkString($var, False); GPBUtil::checkString($var, False);
$this->optional_bytes = $var; $this->optional_bytes = $var;
} }
/**
* <code>optional .foo.TestEnum optional_enum = 16;</code>
*/
public function getOptionalEnum() public function getOptionalEnum()
{ {
return $this->optional_enum; return $this->optional_enum;
} }
/**
* <code>optional .foo.TestEnum optional_enum = 16;</code>
*/
public function setOptionalEnum($var) public function setOptionalEnum($var)
{ {
GPBUtil::checkEnum($var, \Foo\TestEnum::class); GPBUtil::checkEnum($var, \Foo\TestEnum::class);
$this->optional_enum = $var; $this->optional_enum = $var;
} }
/**
* <code>optional .foo.TestMessage.Sub optional_message = 17;</code>
*/
public function getOptionalMessage() public function getOptionalMessage()
{ {
return $this->optional_message; return $this->optional_message;
} }
/**
* <code>optional .foo.TestMessage.Sub optional_message = 17;</code>
*/
public function setOptionalMessage(&$var) public function setOptionalMessage(&$var)
{ {
GPBUtil::checkMessage($var, \Foo\TestMessage_Sub::class); GPBUtil::checkMessage($var, \Foo\TestMessage_Sub::class);
$this->optional_message = $var; $this->optional_message = $var;
} }
/**
* <code>optional .bar.TestInclude optional_included_message = 18;</code>
*/
public function getOptionalIncludedMessage() public function getOptionalIncludedMessage()
{ {
return $this->optional_included_message; return $this->optional_included_message;
} }
/**
* <code>optional .bar.TestInclude optional_included_message = 18;</code>
*/
public function setOptionalIncludedMessage(&$var) public function setOptionalIncludedMessage(&$var)
{ {
GPBUtil::checkMessage($var, \Bar\TestInclude::class); GPBUtil::checkMessage($var, \Bar\TestInclude::class);
$this->optional_included_message = $var; $this->optional_included_message = $var;
} }
/**
* <code>optional .foo.TestMessage recursive = 19;</code>
*/
public function getRecursive() public function getRecursive()
{ {
return $this->recursive; return $this->recursive;
} }
/**
* <code>optional .foo.TestMessage recursive = 19;</code>
*/
public function setRecursive(&$var) public function setRecursive(&$var)
{ {
GPBUtil::checkMessage($var, \Foo\TestMessage::class); GPBUtil::checkMessage($var, \Foo\TestMessage::class);
$this->recursive = $var; $this->recursive = $var;
} }
/**
* <pre>
* Repeated
* </pre>
*
* <code>repeated int32 repeated_int32 = 31;</code>
*/
public function getRepeatedInt32() public function getRepeatedInt32()
{ {
return $this->repeated_int32; return $this->repeated_int32;
} }
/**
* <pre>
* Repeated
* </pre>
*
* <code>repeated int32 repeated_int32 = 31;</code>
*/
public function setRepeatedInt32(&$var) public function setRepeatedInt32(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::INT32); GPBUtil::checkRepeatedField($var, GPBType::INT32);
$this->repeated_int32 = $var; $this->repeated_int32 = $var;
} }
/**
* <code>repeated int64 repeated_int64 = 32;</code>
*/
public function getRepeatedInt64() public function getRepeatedInt64()
{ {
return $this->repeated_int64; return $this->repeated_int64;
} }
/**
* <code>repeated int64 repeated_int64 = 32;</code>
*/
public function setRepeatedInt64(&$var) public function setRepeatedInt64(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::INT64); GPBUtil::checkRepeatedField($var, GPBType::INT64);
$this->repeated_int64 = $var; $this->repeated_int64 = $var;
} }
/**
* <code>repeated uint32 repeated_uint32 = 33;</code>
*/
public function getRepeatedUint32() public function getRepeatedUint32()
{ {
return $this->repeated_uint32; return $this->repeated_uint32;
} }
/**
* <code>repeated uint32 repeated_uint32 = 33;</code>
*/
public function setRepeatedUint32(&$var) public function setRepeatedUint32(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::UINT32); GPBUtil::checkRepeatedField($var, GPBType::UINT32);
$this->repeated_uint32 = $var; $this->repeated_uint32 = $var;
} }
/**
* <code>repeated uint64 repeated_uint64 = 34;</code>
*/
public function getRepeatedUint64() public function getRepeatedUint64()
{ {
return $this->repeated_uint64; return $this->repeated_uint64;
} }
/**
* <code>repeated uint64 repeated_uint64 = 34;</code>
*/
public function setRepeatedUint64(&$var) public function setRepeatedUint64(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::UINT64); GPBUtil::checkRepeatedField($var, GPBType::UINT64);
$this->repeated_uint64 = $var; $this->repeated_uint64 = $var;
} }
/**
* <code>repeated sint32 repeated_sint32 = 35;</code>
*/
public function getRepeatedSint32() public function getRepeatedSint32()
{ {
return $this->repeated_sint32; return $this->repeated_sint32;
} }
/**
* <code>repeated sint32 repeated_sint32 = 35;</code>
*/
public function setRepeatedSint32(&$var) public function setRepeatedSint32(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::SINT32); GPBUtil::checkRepeatedField($var, GPBType::SINT32);
$this->repeated_sint32 = $var; $this->repeated_sint32 = $var;
} }
/**
* <code>repeated sint64 repeated_sint64 = 36;</code>
*/
public function getRepeatedSint64() public function getRepeatedSint64()
{ {
return $this->repeated_sint64; return $this->repeated_sint64;
} }
/**
* <code>repeated sint64 repeated_sint64 = 36;</code>
*/
public function setRepeatedSint64(&$var) public function setRepeatedSint64(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::SINT64); GPBUtil::checkRepeatedField($var, GPBType::SINT64);
$this->repeated_sint64 = $var; $this->repeated_sint64 = $var;
} }
/**
* <code>repeated fixed32 repeated_fixed32 = 37;</code>
*/
public function getRepeatedFixed32() public function getRepeatedFixed32()
{ {
return $this->repeated_fixed32; return $this->repeated_fixed32;
} }
/**
* <code>repeated fixed32 repeated_fixed32 = 37;</code>
*/
public function setRepeatedFixed32(&$var) public function setRepeatedFixed32(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::FIXED32); GPBUtil::checkRepeatedField($var, GPBType::FIXED32);
$this->repeated_fixed32 = $var; $this->repeated_fixed32 = $var;
} }
/**
* <code>repeated fixed64 repeated_fixed64 = 38;</code>
*/
public function getRepeatedFixed64() public function getRepeatedFixed64()
{ {
return $this->repeated_fixed64; return $this->repeated_fixed64;
} }
/**
* <code>repeated fixed64 repeated_fixed64 = 38;</code>
*/
public function setRepeatedFixed64(&$var) public function setRepeatedFixed64(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::FIXED64); GPBUtil::checkRepeatedField($var, GPBType::FIXED64);
$this->repeated_fixed64 = $var; $this->repeated_fixed64 = $var;
} }
/**
* <code>repeated sfixed32 repeated_sfixed32 = 39;</code>
*/
public function getRepeatedSfixed32() public function getRepeatedSfixed32()
{ {
return $this->repeated_sfixed32; return $this->repeated_sfixed32;
} }
/**
* <code>repeated sfixed32 repeated_sfixed32 = 39;</code>
*/
public function setRepeatedSfixed32(&$var) public function setRepeatedSfixed32(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::SFIXED32); GPBUtil::checkRepeatedField($var, GPBType::SFIXED32);
$this->repeated_sfixed32 = $var; $this->repeated_sfixed32 = $var;
} }
/**
* <code>repeated sfixed64 repeated_sfixed64 = 40;</code>
*/
public function getRepeatedSfixed64() public function getRepeatedSfixed64()
{ {
return $this->repeated_sfixed64; return $this->repeated_sfixed64;
} }
/**
* <code>repeated sfixed64 repeated_sfixed64 = 40;</code>
*/
public function setRepeatedSfixed64(&$var) public function setRepeatedSfixed64(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::SFIXED64); GPBUtil::checkRepeatedField($var, GPBType::SFIXED64);
$this->repeated_sfixed64 = $var; $this->repeated_sfixed64 = $var;
} }
/**
* <code>repeated float repeated_float = 41;</code>
*/
public function getRepeatedFloat() public function getRepeatedFloat()
{ {
return $this->repeated_float; return $this->repeated_float;
} }
/**
* <code>repeated float repeated_float = 41;</code>
*/
public function setRepeatedFloat(&$var) public function setRepeatedFloat(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::FLOAT); GPBUtil::checkRepeatedField($var, GPBType::FLOAT);
$this->repeated_float = $var; $this->repeated_float = $var;
} }
/**
* <code>repeated double repeated_double = 42;</code>
*/
public function getRepeatedDouble() public function getRepeatedDouble()
{ {
return $this->repeated_double; return $this->repeated_double;
} }
/**
* <code>repeated double repeated_double = 42;</code>
*/
public function setRepeatedDouble(&$var) public function setRepeatedDouble(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::DOUBLE); GPBUtil::checkRepeatedField($var, GPBType::DOUBLE);
$this->repeated_double = $var; $this->repeated_double = $var;
} }
/**
* <code>repeated bool repeated_bool = 43;</code>
*/
public function getRepeatedBool() public function getRepeatedBool()
{ {
return $this->repeated_bool; return $this->repeated_bool;
} }
/**
* <code>repeated bool repeated_bool = 43;</code>
*/
public function setRepeatedBool(&$var) public function setRepeatedBool(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::BOOL); GPBUtil::checkRepeatedField($var, GPBType::BOOL);
$this->repeated_bool = $var; $this->repeated_bool = $var;
} }
/**
* <code>repeated string repeated_string = 44;</code>
*/
public function getRepeatedString() public function getRepeatedString()
{ {
return $this->repeated_string; return $this->repeated_string;
} }
/**
* <code>repeated string repeated_string = 44;</code>
*/
public function setRepeatedString(&$var) public function setRepeatedString(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::STRING); GPBUtil::checkRepeatedField($var, GPBType::STRING);
$this->repeated_string = $var; $this->repeated_string = $var;
} }
/**
* <code>repeated bytes repeated_bytes = 45;</code>
*/
public function getRepeatedBytes() public function getRepeatedBytes()
{ {
return $this->repeated_bytes; return $this->repeated_bytes;
} }
/**
* <code>repeated bytes repeated_bytes = 45;</code>
*/
public function setRepeatedBytes(&$var) public function setRepeatedBytes(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::BYTES); GPBUtil::checkRepeatedField($var, GPBType::BYTES);
$this->repeated_bytes = $var; $this->repeated_bytes = $var;
} }
/**
* <code>repeated .foo.TestEnum repeated_enum = 46;</code>
*/
public function getRepeatedEnum() public function getRepeatedEnum()
{ {
return $this->repeated_enum; return $this->repeated_enum;
} }
/**
* <code>repeated .foo.TestEnum repeated_enum = 46;</code>
*/
public function setRepeatedEnum(&$var) public function setRepeatedEnum(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::ENUM, Foo\TestEnum::class); GPBUtil::checkRepeatedField($var, GPBType::ENUM, Foo\TestEnum::class);
$this->repeated_enum = $var; $this->repeated_enum = $var;
} }
/**
* <code>repeated .foo.TestMessage.Sub repeated_message = 47;</code>
*/
public function getRepeatedMessage() public function getRepeatedMessage()
{ {
return $this->repeated_message; return $this->repeated_message;
} }
/**
* <code>repeated .foo.TestMessage.Sub repeated_message = 47;</code>
*/
public function setRepeatedMessage(&$var) public function setRepeatedMessage(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Foo\TestMessage_Sub::class); GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Foo\TestMessage_Sub::class);
$this->repeated_message = $var; $this->repeated_message = $var;
} }
/**
* <code>repeated .foo.TestMessage repeated_recursive = 48;</code>
*/
public function getRepeatedRecursive() public function getRepeatedRecursive()
{ {
return $this->repeated_recursive; return $this->repeated_recursive;
} }
/**
* <code>repeated .foo.TestMessage repeated_recursive = 48;</code>
*/
public function setRepeatedRecursive(&$var) public function setRepeatedRecursive(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Foo\TestMessage::class); GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Foo\TestMessage::class);
$this->repeated_recursive = $var; $this->repeated_recursive = $var;
} }
/**
* <code>optional int32 oneof_int32 = 51;</code>
*/
public function getOneofInt32() public function getOneofInt32()
{ {
return $this->readOneof(51); return $this->readOneof(51);
} }
/**
* <code>optional int32 oneof_int32 = 51;</code>
*/
public function setOneofInt32($var) public function setOneofInt32($var)
{ {
GPBUtil::checkInt32($var); GPBUtil::checkInt32($var);
$this->writeOneof(51, $var); $this->writeOneof(51, $var);
} }
/**
* <code>optional int64 oneof_int64 = 52;</code>
*/
public function getOneofInt64() public function getOneofInt64()
{ {
return $this->readOneof(52); return $this->readOneof(52);
} }
/**
* <code>optional int64 oneof_int64 = 52;</code>
*/
public function setOneofInt64($var) public function setOneofInt64($var)
{ {
GPBUtil::checkInt64($var); GPBUtil::checkInt64($var);
$this->writeOneof(52, $var); $this->writeOneof(52, $var);
} }
/**
* <code>optional uint32 oneof_uint32 = 53;</code>
*/
public function getOneofUint32() public function getOneofUint32()
{ {
return $this->readOneof(53); return $this->readOneof(53);
} }
/**
* <code>optional uint32 oneof_uint32 = 53;</code>
*/
public function setOneofUint32($var) public function setOneofUint32($var)
{ {
GPBUtil::checkUint32($var); GPBUtil::checkUint32($var);
$this->writeOneof(53, $var); $this->writeOneof(53, $var);
} }
/**
* <code>optional uint64 oneof_uint64 = 54;</code>
*/
public function getOneofUint64() public function getOneofUint64()
{ {
return $this->readOneof(54); return $this->readOneof(54);
} }
/**
* <code>optional uint64 oneof_uint64 = 54;</code>
*/
public function setOneofUint64($var) public function setOneofUint64($var)
{ {
GPBUtil::checkUint64($var); GPBUtil::checkUint64($var);
$this->writeOneof(54, $var); $this->writeOneof(54, $var);
} }
/**
* <code>optional uint32 oneof_sint32 = 55;</code>
*/
public function getOneofSint32() public function getOneofSint32()
{ {
return $this->readOneof(55); return $this->readOneof(55);
} }
/**
* <code>optional uint32 oneof_sint32 = 55;</code>
*/
public function setOneofSint32($var) public function setOneofSint32($var)
{ {
GPBUtil::checkUint32($var); GPBUtil::checkUint32($var);
$this->writeOneof(55, $var); $this->writeOneof(55, $var);
} }
/**
* <code>optional uint64 oneof_sint64 = 56;</code>
*/
public function getOneofSint64() public function getOneofSint64()
{ {
return $this->readOneof(56); return $this->readOneof(56);
} }
/**
* <code>optional uint64 oneof_sint64 = 56;</code>
*/
public function setOneofSint64($var) public function setOneofSint64($var)
{ {
GPBUtil::checkUint64($var); GPBUtil::checkUint64($var);
$this->writeOneof(56, $var); $this->writeOneof(56, $var);
} }
/**
* <code>optional uint32 oneof_fixed32 = 57;</code>
*/
public function getOneofFixed32() public function getOneofFixed32()
{ {
return $this->readOneof(57); return $this->readOneof(57);
} }
/**
* <code>optional uint32 oneof_fixed32 = 57;</code>
*/
public function setOneofFixed32($var) public function setOneofFixed32($var)
{ {
GPBUtil::checkUint32($var); GPBUtil::checkUint32($var);
$this->writeOneof(57, $var); $this->writeOneof(57, $var);
} }
/**
* <code>optional uint64 oneof_fixed64 = 58;</code>
*/
public function getOneofFixed64() public function getOneofFixed64()
{ {
return $this->readOneof(58); return $this->readOneof(58);
} }
/**
* <code>optional uint64 oneof_fixed64 = 58;</code>
*/
public function setOneofFixed64($var) public function setOneofFixed64($var)
{ {
GPBUtil::checkUint64($var); GPBUtil::checkUint64($var);
$this->writeOneof(58, $var); $this->writeOneof(58, $var);
} }
/**
* <code>optional uint32 oneof_sfixed32 = 59;</code>
*/
public function getOneofSfixed32() public function getOneofSfixed32()
{ {
return $this->readOneof(59); return $this->readOneof(59);
} }
/**
* <code>optional uint32 oneof_sfixed32 = 59;</code>
*/
public function setOneofSfixed32($var) public function setOneofSfixed32($var)
{ {
GPBUtil::checkUint32($var); GPBUtil::checkUint32($var);
$this->writeOneof(59, $var); $this->writeOneof(59, $var);
} }
/**
* <code>optional uint64 oneof_sfixed64 = 60;</code>
*/
public function getOneofSfixed64() public function getOneofSfixed64()
{ {
return $this->readOneof(60); return $this->readOneof(60);
} }
/**
* <code>optional uint64 oneof_sfixed64 = 60;</code>
*/
public function setOneofSfixed64($var) public function setOneofSfixed64($var)
{ {
GPBUtil::checkUint64($var); GPBUtil::checkUint64($var);
$this->writeOneof(60, $var); $this->writeOneof(60, $var);
} }
/**
* <code>optional double oneof_double = 61;</code>
*/
public function getOneofDouble() public function getOneofDouble()
{ {
return $this->readOneof(61); return $this->readOneof(61);
} }
/**
* <code>optional double oneof_double = 61;</code>
*/
public function setOneofDouble($var) public function setOneofDouble($var)
{ {
GPBUtil::checkDouble($var); GPBUtil::checkDouble($var);
$this->writeOneof(61, $var); $this->writeOneof(61, $var);
} }
/**
* <code>optional float oneof_float = 62;</code>
*/
public function getOneofFloat() public function getOneofFloat()
{ {
return $this->readOneof(62); return $this->readOneof(62);
} }
/**
* <code>optional float oneof_float = 62;</code>
*/
public function setOneofFloat($var) public function setOneofFloat($var)
{ {
GPBUtil::checkFloat($var); GPBUtil::checkFloat($var);
$this->writeOneof(62, $var); $this->writeOneof(62, $var);
} }
/**
* <code>optional bool oneof_bool = 63;</code>
*/
public function getOneofBool() public function getOneofBool()
{ {
return $this->readOneof(63); return $this->readOneof(63);
} }
/**
* <code>optional bool oneof_bool = 63;</code>
*/
public function setOneofBool($var) public function setOneofBool($var)
{ {
GPBUtil::checkBool($var); GPBUtil::checkBool($var);
$this->writeOneof(63, $var); $this->writeOneof(63, $var);
} }
/**
* <code>optional string oneof_string = 64;</code>
*/
public function getOneofString() public function getOneofString()
{ {
return $this->readOneof(64); return $this->readOneof(64);
} }
/**
* <code>optional string oneof_string = 64;</code>
*/
public function setOneofString($var) public function setOneofString($var)
{ {
GPBUtil::checkString($var, True); GPBUtil::checkString($var, True);
$this->writeOneof(64, $var); $this->writeOneof(64, $var);
} }
/**
* <code>optional bytes oneof_bytes = 65;</code>
*/
public function getOneofBytes() public function getOneofBytes()
{ {
return $this->readOneof(65); return $this->readOneof(65);
} }
/**
* <code>optional bytes oneof_bytes = 65;</code>
*/
public function setOneofBytes($var) public function setOneofBytes($var)
{ {
GPBUtil::checkString($var, False); GPBUtil::checkString($var, False);
$this->writeOneof(65, $var); $this->writeOneof(65, $var);
} }
/**
* <code>optional .foo.TestEnum oneof_enum = 66;</code>
*/
public function getOneofEnum() public function getOneofEnum()
{ {
return $this->readOneof(66); return $this->readOneof(66);
} }
/**
* <code>optional .foo.TestEnum oneof_enum = 66;</code>
*/
public function setOneofEnum($var) public function setOneofEnum($var)
{ {
GPBUtil::checkEnum($var, \Foo\TestEnum::class); GPBUtil::checkEnum($var, \Foo\TestEnum::class);
$this->writeOneof(66, $var); $this->writeOneof(66, $var);
} }
/**
* <code>optional .foo.TestMessage.Sub oneof_message = 67;</code>
*/
public function getOneofMessage() public function getOneofMessage()
{ {
return $this->readOneof(67); return $this->readOneof(67);
} }
/**
* <code>optional .foo.TestMessage.Sub oneof_message = 67;</code>
*/
public function setOneofMessage(&$var) public function setOneofMessage(&$var)
{ {
GPBUtil::checkMessage($var, \Foo\TestMessage_Sub::class); GPBUtil::checkMessage($var, \Foo\TestMessage_Sub::class);
$this->writeOneof(67, $var); $this->writeOneof(67, $var);
} }
/**
* <code>map&lt;int32, int32&gt; map_int32_int32 = 71;</code>
*/
public function getMapInt32Int32() public function getMapInt32Int32()
{ {
return $this->map_int32_int32; return $this->map_int32_int32;
} }
/**
* <code>map&lt;int32, int32&gt; map_int32_int32 = 71;</code>
*/
public function setMapInt32Int32(&$var) public function setMapInt32Int32(&$var)
{ {
$this->map_int32_int32 = $var; $this->map_int32_int32 = $var;
} }
/**
* <code>map&lt;int64, int64&gt; map_int64_int64 = 72;</code>
*/
public function getMapInt64Int64() public function getMapInt64Int64()
{ {
return $this->map_int64_int64; return $this->map_int64_int64;
} }
/**
* <code>map&lt;int64, int64&gt; map_int64_int64 = 72;</code>
*/
public function setMapInt64Int64(&$var) public function setMapInt64Int64(&$var)
{ {
$this->map_int64_int64 = $var; $this->map_int64_int64 = $var;
} }
/**
* <code>map&lt;uint32, uint32&gt; map_uint32_uint32 = 73;</code>
*/
public function getMapUint32Uint32() public function getMapUint32Uint32()
{ {
return $this->map_uint32_uint32; return $this->map_uint32_uint32;
} }
/**
* <code>map&lt;uint32, uint32&gt; map_uint32_uint32 = 73;</code>
*/
public function setMapUint32Uint32(&$var) public function setMapUint32Uint32(&$var)
{ {
$this->map_uint32_uint32 = $var; $this->map_uint32_uint32 = $var;
} }
/**
* <code>map&lt;uint64, uint64&gt; map_uint64_uint64 = 74;</code>
*/
public function getMapUint64Uint64() public function getMapUint64Uint64()
{ {
return $this->map_uint64_uint64; return $this->map_uint64_uint64;
} }
/**
* <code>map&lt;uint64, uint64&gt; map_uint64_uint64 = 74;</code>
*/
public function setMapUint64Uint64(&$var) public function setMapUint64Uint64(&$var)
{ {
$this->map_uint64_uint64 = $var; $this->map_uint64_uint64 = $var;
} }
/**
* <code>map&lt;sint32, sint32&gt; map_sint32_sint32 = 75;</code>
*/
public function getMapSint32Sint32() public function getMapSint32Sint32()
{ {
return $this->map_sint32_sint32; return $this->map_sint32_sint32;
} }
/**
* <code>map&lt;sint32, sint32&gt; map_sint32_sint32 = 75;</code>
*/
public function setMapSint32Sint32(&$var) public function setMapSint32Sint32(&$var)
{ {
$this->map_sint32_sint32 = $var; $this->map_sint32_sint32 = $var;
} }
/**
* <code>map&lt;sint64, sint64&gt; map_sint64_sint64 = 76;</code>
*/
public function getMapSint64Sint64() public function getMapSint64Sint64()
{ {
return $this->map_sint64_sint64; return $this->map_sint64_sint64;
} }
/**
* <code>map&lt;sint64, sint64&gt; map_sint64_sint64 = 76;</code>
*/
public function setMapSint64Sint64(&$var) public function setMapSint64Sint64(&$var)
{ {
$this->map_sint64_sint64 = $var; $this->map_sint64_sint64 = $var;
} }
/**
* <code>map&lt;fixed32, fixed32&gt; map_fixed32_fixed32 = 77;</code>
*/
public function getMapFixed32Fixed32() public function getMapFixed32Fixed32()
{ {
return $this->map_fixed32_fixed32; return $this->map_fixed32_fixed32;
} }
/**
* <code>map&lt;fixed32, fixed32&gt; map_fixed32_fixed32 = 77;</code>
*/
public function setMapFixed32Fixed32(&$var) public function setMapFixed32Fixed32(&$var)
{ {
$this->map_fixed32_fixed32 = $var; $this->map_fixed32_fixed32 = $var;
} }
/**
* <code>map&lt;fixed64, fixed64&gt; map_fixed64_fixed64 = 78;</code>
*/
public function getMapFixed64Fixed64() public function getMapFixed64Fixed64()
{ {
return $this->map_fixed64_fixed64; return $this->map_fixed64_fixed64;
} }
/**
* <code>map&lt;fixed64, fixed64&gt; map_fixed64_fixed64 = 78;</code>
*/
public function setMapFixed64Fixed64(&$var) public function setMapFixed64Fixed64(&$var)
{ {
$this->map_fixed64_fixed64 = $var; $this->map_fixed64_fixed64 = $var;
} }
/**
* <code>map&lt;sfixed32, sfixed32&gt; map_sfixed32_sfixed32 = 79;</code>
*/
public function getMapSfixed32Sfixed32() public function getMapSfixed32Sfixed32()
{ {
return $this->map_sfixed32_sfixed32; return $this->map_sfixed32_sfixed32;
} }
/**
* <code>map&lt;sfixed32, sfixed32&gt; map_sfixed32_sfixed32 = 79;</code>
*/
public function setMapSfixed32Sfixed32(&$var) public function setMapSfixed32Sfixed32(&$var)
{ {
$this->map_sfixed32_sfixed32 = $var; $this->map_sfixed32_sfixed32 = $var;
} }
/**
* <code>map&lt;sfixed64, sfixed64&gt; map_sfixed64_sfixed64 = 80;</code>
*/
public function getMapSfixed64Sfixed64() public function getMapSfixed64Sfixed64()
{ {
return $this->map_sfixed64_sfixed64; return $this->map_sfixed64_sfixed64;
} }
/**
* <code>map&lt;sfixed64, sfixed64&gt; map_sfixed64_sfixed64 = 80;</code>
*/
public function setMapSfixed64Sfixed64(&$var) public function setMapSfixed64Sfixed64(&$var)
{ {
$this->map_sfixed64_sfixed64 = $var; $this->map_sfixed64_sfixed64 = $var;
} }
/**
* <code>map&lt;int32, float&gt; map_int32_float = 81;</code>
*/
public function getMapInt32Float() public function getMapInt32Float()
{ {
return $this->map_int32_float; return $this->map_int32_float;
} }
/**
* <code>map&lt;int32, float&gt; map_int32_float = 81;</code>
*/
public function setMapInt32Float(&$var) public function setMapInt32Float(&$var)
{ {
$this->map_int32_float = $var; $this->map_int32_float = $var;
} }
/**
* <code>map&lt;int32, double&gt; map_int32_double = 82;</code>
*/
public function getMapInt32Double() public function getMapInt32Double()
{ {
return $this->map_int32_double; return $this->map_int32_double;
} }
/**
* <code>map&lt;int32, double&gt; map_int32_double = 82;</code>
*/
public function setMapInt32Double(&$var) public function setMapInt32Double(&$var)
{ {
$this->map_int32_double = $var; $this->map_int32_double = $var;
} }
/**
* <code>map&lt;bool, bool&gt; map_bool_bool = 83;</code>
*/
public function getMapBoolBool() public function getMapBoolBool()
{ {
return $this->map_bool_bool; return $this->map_bool_bool;
} }
/**
* <code>map&lt;bool, bool&gt; map_bool_bool = 83;</code>
*/
public function setMapBoolBool(&$var) public function setMapBoolBool(&$var)
{ {
$this->map_bool_bool = $var; $this->map_bool_bool = $var;
} }
/**
* <code>map&lt;string, string&gt; map_string_string = 84;</code>
*/
public function getMapStringString() public function getMapStringString()
{ {
return $this->map_string_string; return $this->map_string_string;
} }
/**
* <code>map&lt;string, string&gt; map_string_string = 84;</code>
*/
public function setMapStringString(&$var) public function setMapStringString(&$var)
{ {
$this->map_string_string = $var; $this->map_string_string = $var;
} }
/**
* <code>map&lt;int32, bytes&gt; map_int32_bytes = 85;</code>
*/
public function getMapInt32Bytes() public function getMapInt32Bytes()
{ {
return $this->map_int32_bytes; return $this->map_int32_bytes;
} }
/**
* <code>map&lt;int32, bytes&gt; map_int32_bytes = 85;</code>
*/
public function setMapInt32Bytes(&$var) public function setMapInt32Bytes(&$var)
{ {
$this->map_int32_bytes = $var; $this->map_int32_bytes = $var;
} }
/**
* <code>map&lt;int32, .foo.TestEnum&gt; map_int32_enum = 86;</code>
*/
public function getMapInt32Enum() public function getMapInt32Enum()
{ {
return $this->map_int32_enum; return $this->map_int32_enum;
} }
/**
* <code>map&lt;int32, .foo.TestEnum&gt; map_int32_enum = 86;</code>
*/
public function setMapInt32Enum(&$var) public function setMapInt32Enum(&$var)
{ {
$this->map_int32_enum = $var; $this->map_int32_enum = $var;
} }
/**
* <code>map&lt;int32, .foo.TestMessage.Sub&gt; map_int32_message = 87;</code>
*/
public function getMapInt32Message() public function getMapInt32Message()
{ {
return $this->map_int32_message; return $this->map_int32_message;
} }
/**
* <code>map&lt;int32, .foo.TestMessage.Sub&gt; map_int32_message = 87;</code>
*/
public function setMapInt32Message(&$var) public function setMapInt32Message(&$var)
{ {
$this->map_int32_message = $var; $this->map_int32_message = $var;
} }
/**
* <code>map&lt;int32, .foo.TestMessage&gt; map_recursive = 88;</code>
*/
public function getMapRecursive() public function getMapRecursive()
{ {
return $this->map_recursive; return $this->map_recursive;
} }
/**
* <code>map&lt;int32, .foo.TestMessage&gt; map_recursive = 88;</code>
*/
public function setMapRecursive(&$var) public function setMapRecursive(&$var)
{ {
$this->map_recursive = $var; $this->map_recursive = $var;
...@@ -850,15 +1474,27 @@ class TestMessage extends \Google\Protobuf\Internal\Message ...@@ -850,15 +1474,27 @@ class TestMessage extends \Google\Protobuf\Internal\Message
} }
/**
* Protobuf type <code>foo.TestMessage.Sub</code>
*/
class TestMessage_Sub extends \Google\Protobuf\Internal\Message class TestMessage_Sub extends \Google\Protobuf\Internal\Message
{ {
/**
* <code>optional int32 a = 1;</code>
*/
private $a = 0; private $a = 0;
/**
* <code>optional int32 a = 1;</code>
*/
public function getA() public function getA()
{ {
return $this->a; return $this->a;
} }
/**
* <code>optional int32 a = 1;</code>
*/
public function setA($var) public function setA($var)
{ {
GPBUtil::checkInt32($var); GPBUtil::checkInt32($var);
...@@ -867,171 +1503,300 @@ class TestMessage_Sub extends \Google\Protobuf\Internal\Message ...@@ -867,171 +1503,300 @@ class TestMessage_Sub extends \Google\Protobuf\Internal\Message
} }
/**
* Protobuf type <code>foo.TestPackedMessage</code>
*/
class TestPackedMessage extends \Google\Protobuf\Internal\Message class TestPackedMessage extends \Google\Protobuf\Internal\Message
{ {
/**
* <code>repeated int32 repeated_int32 = 90 [packed = true];</code>
*/
private $repeated_int32; private $repeated_int32;
/**
* <code>repeated int64 repeated_int64 = 91 [packed = true];</code>
*/
private $repeated_int64; private $repeated_int64;
/**
* <code>repeated uint32 repeated_uint32 = 92 [packed = true];</code>
*/
private $repeated_uint32; private $repeated_uint32;
/**
* <code>repeated uint64 repeated_uint64 = 93 [packed = true];</code>
*/
private $repeated_uint64; private $repeated_uint64;
/**
* <code>repeated sint32 repeated_sint32 = 94 [packed = true];</code>
*/
private $repeated_sint32; private $repeated_sint32;
/**
* <code>repeated sint64 repeated_sint64 = 95 [packed = true];</code>
*/
private $repeated_sint64; private $repeated_sint64;
/**
* <code>repeated fixed32 repeated_fixed32 = 96 [packed = true];</code>
*/
private $repeated_fixed32; private $repeated_fixed32;
/**
* <code>repeated fixed64 repeated_fixed64 = 97 [packed = true];</code>
*/
private $repeated_fixed64; private $repeated_fixed64;
/**
* <code>repeated sfixed32 repeated_sfixed32 = 98 [packed = true];</code>
*/
private $repeated_sfixed32; private $repeated_sfixed32;
/**
* <code>repeated sfixed64 repeated_sfixed64 = 99 [packed = true];</code>
*/
private $repeated_sfixed64; private $repeated_sfixed64;
/**
* <code>repeated float repeated_float = 100 [packed = true];</code>
*/
private $repeated_float; private $repeated_float;
/**
* <code>repeated double repeated_double = 101 [packed = true];</code>
*/
private $repeated_double; private $repeated_double;
/**
* <code>repeated bool repeated_bool = 102 [packed = true];</code>
*/
private $repeated_bool; private $repeated_bool;
/**
* <code>repeated .foo.TestEnum repeated_enum = 103 [packed = true];</code>
*/
private $repeated_enum; private $repeated_enum;
/**
* <code>repeated int32 repeated_int32 = 90 [packed = true];</code>
*/
public function getRepeatedInt32() public function getRepeatedInt32()
{ {
return $this->repeated_int32; return $this->repeated_int32;
} }
/**
* <code>repeated int32 repeated_int32 = 90 [packed = true];</code>
*/
public function setRepeatedInt32(&$var) public function setRepeatedInt32(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::INT32); GPBUtil::checkRepeatedField($var, GPBType::INT32);
$this->repeated_int32 = $var; $this->repeated_int32 = $var;
} }
/**
* <code>repeated int64 repeated_int64 = 91 [packed = true];</code>
*/
public function getRepeatedInt64() public function getRepeatedInt64()
{ {
return $this->repeated_int64; return $this->repeated_int64;
} }
/**
* <code>repeated int64 repeated_int64 = 91 [packed = true];</code>
*/
public function setRepeatedInt64(&$var) public function setRepeatedInt64(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::INT64); GPBUtil::checkRepeatedField($var, GPBType::INT64);
$this->repeated_int64 = $var; $this->repeated_int64 = $var;
} }
/**
* <code>repeated uint32 repeated_uint32 = 92 [packed = true];</code>
*/
public function getRepeatedUint32() public function getRepeatedUint32()
{ {
return $this->repeated_uint32; return $this->repeated_uint32;
} }
/**
* <code>repeated uint32 repeated_uint32 = 92 [packed = true];</code>
*/
public function setRepeatedUint32(&$var) public function setRepeatedUint32(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::UINT32); GPBUtil::checkRepeatedField($var, GPBType::UINT32);
$this->repeated_uint32 = $var; $this->repeated_uint32 = $var;
} }
/**
* <code>repeated uint64 repeated_uint64 = 93 [packed = true];</code>
*/
public function getRepeatedUint64() public function getRepeatedUint64()
{ {
return $this->repeated_uint64; return $this->repeated_uint64;
} }
/**
* <code>repeated uint64 repeated_uint64 = 93 [packed = true];</code>
*/
public function setRepeatedUint64(&$var) public function setRepeatedUint64(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::UINT64); GPBUtil::checkRepeatedField($var, GPBType::UINT64);
$this->repeated_uint64 = $var; $this->repeated_uint64 = $var;
} }
/**
* <code>repeated sint32 repeated_sint32 = 94 [packed = true];</code>
*/
public function getRepeatedSint32() public function getRepeatedSint32()
{ {
return $this->repeated_sint32; return $this->repeated_sint32;
} }
/**
* <code>repeated sint32 repeated_sint32 = 94 [packed = true];</code>
*/
public function setRepeatedSint32(&$var) public function setRepeatedSint32(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::SINT32); GPBUtil::checkRepeatedField($var, GPBType::SINT32);
$this->repeated_sint32 = $var; $this->repeated_sint32 = $var;
} }
/**
* <code>repeated sint64 repeated_sint64 = 95 [packed = true];</code>
*/
public function getRepeatedSint64() public function getRepeatedSint64()
{ {
return $this->repeated_sint64; return $this->repeated_sint64;
} }
/**
* <code>repeated sint64 repeated_sint64 = 95 [packed = true];</code>
*/
public function setRepeatedSint64(&$var) public function setRepeatedSint64(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::SINT64); GPBUtil::checkRepeatedField($var, GPBType::SINT64);
$this->repeated_sint64 = $var; $this->repeated_sint64 = $var;
} }
/**
* <code>repeated fixed32 repeated_fixed32 = 96 [packed = true];</code>
*/
public function getRepeatedFixed32() public function getRepeatedFixed32()
{ {
return $this->repeated_fixed32; return $this->repeated_fixed32;
} }
/**
* <code>repeated fixed32 repeated_fixed32 = 96 [packed = true];</code>
*/
public function setRepeatedFixed32(&$var) public function setRepeatedFixed32(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::FIXED32); GPBUtil::checkRepeatedField($var, GPBType::FIXED32);
$this->repeated_fixed32 = $var; $this->repeated_fixed32 = $var;
} }
/**
* <code>repeated fixed64 repeated_fixed64 = 97 [packed = true];</code>
*/
public function getRepeatedFixed64() public function getRepeatedFixed64()
{ {
return $this->repeated_fixed64; return $this->repeated_fixed64;
} }
/**
* <code>repeated fixed64 repeated_fixed64 = 97 [packed = true];</code>
*/
public function setRepeatedFixed64(&$var) public function setRepeatedFixed64(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::FIXED64); GPBUtil::checkRepeatedField($var, GPBType::FIXED64);
$this->repeated_fixed64 = $var; $this->repeated_fixed64 = $var;
} }
/**
* <code>repeated sfixed32 repeated_sfixed32 = 98 [packed = true];</code>
*/
public function getRepeatedSfixed32() public function getRepeatedSfixed32()
{ {
return $this->repeated_sfixed32; return $this->repeated_sfixed32;
} }
/**
* <code>repeated sfixed32 repeated_sfixed32 = 98 [packed = true];</code>
*/
public function setRepeatedSfixed32(&$var) public function setRepeatedSfixed32(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::SFIXED32); GPBUtil::checkRepeatedField($var, GPBType::SFIXED32);
$this->repeated_sfixed32 = $var; $this->repeated_sfixed32 = $var;
} }
/**
* <code>repeated sfixed64 repeated_sfixed64 = 99 [packed = true];</code>
*/
public function getRepeatedSfixed64() public function getRepeatedSfixed64()
{ {
return $this->repeated_sfixed64; return $this->repeated_sfixed64;
} }
/**
* <code>repeated sfixed64 repeated_sfixed64 = 99 [packed = true];</code>
*/
public function setRepeatedSfixed64(&$var) public function setRepeatedSfixed64(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::SFIXED64); GPBUtil::checkRepeatedField($var, GPBType::SFIXED64);
$this->repeated_sfixed64 = $var; $this->repeated_sfixed64 = $var;
} }
/**
* <code>repeated float repeated_float = 100 [packed = true];</code>
*/
public function getRepeatedFloat() public function getRepeatedFloat()
{ {
return $this->repeated_float; return $this->repeated_float;
} }
/**
* <code>repeated float repeated_float = 100 [packed = true];</code>
*/
public function setRepeatedFloat(&$var) public function setRepeatedFloat(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::FLOAT); GPBUtil::checkRepeatedField($var, GPBType::FLOAT);
$this->repeated_float = $var; $this->repeated_float = $var;
} }
/**
* <code>repeated double repeated_double = 101 [packed = true];</code>
*/
public function getRepeatedDouble() public function getRepeatedDouble()
{ {
return $this->repeated_double; return $this->repeated_double;
} }
/**
* <code>repeated double repeated_double = 101 [packed = true];</code>
*/
public function setRepeatedDouble(&$var) public function setRepeatedDouble(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::DOUBLE); GPBUtil::checkRepeatedField($var, GPBType::DOUBLE);
$this->repeated_double = $var; $this->repeated_double = $var;
} }
/**
* <code>repeated bool repeated_bool = 102 [packed = true];</code>
*/
public function getRepeatedBool() public function getRepeatedBool()
{ {
return $this->repeated_bool; return $this->repeated_bool;
} }
/**
* <code>repeated bool repeated_bool = 102 [packed = true];</code>
*/
public function setRepeatedBool(&$var) public function setRepeatedBool(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::BOOL); GPBUtil::checkRepeatedField($var, GPBType::BOOL);
$this->repeated_bool = $var; $this->repeated_bool = $var;
} }
/**
* <code>repeated .foo.TestEnum repeated_enum = 103 [packed = true];</code>
*/
public function getRepeatedEnum() public function getRepeatedEnum()
{ {
return $this->repeated_enum; return $this->repeated_enum;
} }
/**
* <code>repeated .foo.TestEnum repeated_enum = 103 [packed = true];</code>
*/
public function setRepeatedEnum(&$var) public function setRepeatedEnum(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::ENUM, Foo\TestEnum::class); GPBUtil::checkRepeatedField($var, GPBType::ENUM, Foo\TestEnum::class);
...@@ -1040,171 +1805,304 @@ class TestPackedMessage extends \Google\Protobuf\Internal\Message ...@@ -1040,171 +1805,304 @@ class TestPackedMessage extends \Google\Protobuf\Internal\Message
} }
/**
* <pre>
* Need to be in sync with TestPackedMessage.
* </pre>
*
* Protobuf type <code>foo.TestUnpackedMessage</code>
*/
class TestUnpackedMessage extends \Google\Protobuf\Internal\Message class TestUnpackedMessage extends \Google\Protobuf\Internal\Message
{ {
/**
* <code>repeated int32 repeated_int32 = 90 [packed = false];</code>
*/
private $repeated_int32; private $repeated_int32;
/**
* <code>repeated int64 repeated_int64 = 91 [packed = false];</code>
*/
private $repeated_int64; private $repeated_int64;
/**
* <code>repeated uint32 repeated_uint32 = 92 [packed = false];</code>
*/
private $repeated_uint32; private $repeated_uint32;
/**
* <code>repeated uint64 repeated_uint64 = 93 [packed = false];</code>
*/
private $repeated_uint64; private $repeated_uint64;
/**
* <code>repeated sint32 repeated_sint32 = 94 [packed = false];</code>
*/
private $repeated_sint32; private $repeated_sint32;
/**
* <code>repeated sint64 repeated_sint64 = 95 [packed = false];</code>
*/
private $repeated_sint64; private $repeated_sint64;
/**
* <code>repeated fixed32 repeated_fixed32 = 96 [packed = false];</code>
*/
private $repeated_fixed32; private $repeated_fixed32;
/**
* <code>repeated fixed64 repeated_fixed64 = 97 [packed = false];</code>
*/
private $repeated_fixed64; private $repeated_fixed64;
/**
* <code>repeated sfixed32 repeated_sfixed32 = 98 [packed = false];</code>
*/
private $repeated_sfixed32; private $repeated_sfixed32;
/**
* <code>repeated sfixed64 repeated_sfixed64 = 99 [packed = false];</code>
*/
private $repeated_sfixed64; private $repeated_sfixed64;
/**
* <code>repeated float repeated_float = 100 [packed = false];</code>
*/
private $repeated_float; private $repeated_float;
/**
* <code>repeated double repeated_double = 101 [packed = false];</code>
*/
private $repeated_double; private $repeated_double;
/**
* <code>repeated bool repeated_bool = 102 [packed = false];</code>
*/
private $repeated_bool; private $repeated_bool;
/**
* <code>repeated .foo.TestEnum repeated_enum = 103 [packed = false];</code>
*/
private $repeated_enum; private $repeated_enum;
/**
* <code>repeated int32 repeated_int32 = 90 [packed = false];</code>
*/
public function getRepeatedInt32() public function getRepeatedInt32()
{ {
return $this->repeated_int32; return $this->repeated_int32;
} }
/**
* <code>repeated int32 repeated_int32 = 90 [packed = false];</code>
*/
public function setRepeatedInt32(&$var) public function setRepeatedInt32(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::INT32); GPBUtil::checkRepeatedField($var, GPBType::INT32);
$this->repeated_int32 = $var; $this->repeated_int32 = $var;
} }
/**
* <code>repeated int64 repeated_int64 = 91 [packed = false];</code>
*/
public function getRepeatedInt64() public function getRepeatedInt64()
{ {
return $this->repeated_int64; return $this->repeated_int64;
} }
/**
* <code>repeated int64 repeated_int64 = 91 [packed = false];</code>
*/
public function setRepeatedInt64(&$var) public function setRepeatedInt64(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::INT64); GPBUtil::checkRepeatedField($var, GPBType::INT64);
$this->repeated_int64 = $var; $this->repeated_int64 = $var;
} }
/**
* <code>repeated uint32 repeated_uint32 = 92 [packed = false];</code>
*/
public function getRepeatedUint32() public function getRepeatedUint32()
{ {
return $this->repeated_uint32; return $this->repeated_uint32;
} }
/**
* <code>repeated uint32 repeated_uint32 = 92 [packed = false];</code>
*/
public function setRepeatedUint32(&$var) public function setRepeatedUint32(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::UINT32); GPBUtil::checkRepeatedField($var, GPBType::UINT32);
$this->repeated_uint32 = $var; $this->repeated_uint32 = $var;
} }
/**
* <code>repeated uint64 repeated_uint64 = 93 [packed = false];</code>
*/
public function getRepeatedUint64() public function getRepeatedUint64()
{ {
return $this->repeated_uint64; return $this->repeated_uint64;
} }
/**
* <code>repeated uint64 repeated_uint64 = 93 [packed = false];</code>
*/
public function setRepeatedUint64(&$var) public function setRepeatedUint64(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::UINT64); GPBUtil::checkRepeatedField($var, GPBType::UINT64);
$this->repeated_uint64 = $var; $this->repeated_uint64 = $var;
} }
/**
* <code>repeated sint32 repeated_sint32 = 94 [packed = false];</code>
*/
public function getRepeatedSint32() public function getRepeatedSint32()
{ {
return $this->repeated_sint32; return $this->repeated_sint32;
} }
/**
* <code>repeated sint32 repeated_sint32 = 94 [packed = false];</code>
*/
public function setRepeatedSint32(&$var) public function setRepeatedSint32(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::SINT32); GPBUtil::checkRepeatedField($var, GPBType::SINT32);
$this->repeated_sint32 = $var; $this->repeated_sint32 = $var;
} }
/**
* <code>repeated sint64 repeated_sint64 = 95 [packed = false];</code>
*/
public function getRepeatedSint64() public function getRepeatedSint64()
{ {
return $this->repeated_sint64; return $this->repeated_sint64;
} }
/**
* <code>repeated sint64 repeated_sint64 = 95 [packed = false];</code>
*/
public function setRepeatedSint64(&$var) public function setRepeatedSint64(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::SINT64); GPBUtil::checkRepeatedField($var, GPBType::SINT64);
$this->repeated_sint64 = $var; $this->repeated_sint64 = $var;
} }
/**
* <code>repeated fixed32 repeated_fixed32 = 96 [packed = false];</code>
*/
public function getRepeatedFixed32() public function getRepeatedFixed32()
{ {
return $this->repeated_fixed32; return $this->repeated_fixed32;
} }
/**
* <code>repeated fixed32 repeated_fixed32 = 96 [packed = false];</code>
*/
public function setRepeatedFixed32(&$var) public function setRepeatedFixed32(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::FIXED32); GPBUtil::checkRepeatedField($var, GPBType::FIXED32);
$this->repeated_fixed32 = $var; $this->repeated_fixed32 = $var;
} }
/**
* <code>repeated fixed64 repeated_fixed64 = 97 [packed = false];</code>
*/
public function getRepeatedFixed64() public function getRepeatedFixed64()
{ {
return $this->repeated_fixed64; return $this->repeated_fixed64;
} }
/**
* <code>repeated fixed64 repeated_fixed64 = 97 [packed = false];</code>
*/
public function setRepeatedFixed64(&$var) public function setRepeatedFixed64(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::FIXED64); GPBUtil::checkRepeatedField($var, GPBType::FIXED64);
$this->repeated_fixed64 = $var; $this->repeated_fixed64 = $var;
} }
/**
* <code>repeated sfixed32 repeated_sfixed32 = 98 [packed = false];</code>
*/
public function getRepeatedSfixed32() public function getRepeatedSfixed32()
{ {
return $this->repeated_sfixed32; return $this->repeated_sfixed32;
} }
/**
* <code>repeated sfixed32 repeated_sfixed32 = 98 [packed = false];</code>
*/
public function setRepeatedSfixed32(&$var) public function setRepeatedSfixed32(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::SFIXED32); GPBUtil::checkRepeatedField($var, GPBType::SFIXED32);
$this->repeated_sfixed32 = $var; $this->repeated_sfixed32 = $var;
} }
/**
* <code>repeated sfixed64 repeated_sfixed64 = 99 [packed = false];</code>
*/
public function getRepeatedSfixed64() public function getRepeatedSfixed64()
{ {
return $this->repeated_sfixed64; return $this->repeated_sfixed64;
} }
/**
* <code>repeated sfixed64 repeated_sfixed64 = 99 [packed = false];</code>
*/
public function setRepeatedSfixed64(&$var) public function setRepeatedSfixed64(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::SFIXED64); GPBUtil::checkRepeatedField($var, GPBType::SFIXED64);
$this->repeated_sfixed64 = $var; $this->repeated_sfixed64 = $var;
} }
/**
* <code>repeated float repeated_float = 100 [packed = false];</code>
*/
public function getRepeatedFloat() public function getRepeatedFloat()
{ {
return $this->repeated_float; return $this->repeated_float;
} }
/**
* <code>repeated float repeated_float = 100 [packed = false];</code>
*/
public function setRepeatedFloat(&$var) public function setRepeatedFloat(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::FLOAT); GPBUtil::checkRepeatedField($var, GPBType::FLOAT);
$this->repeated_float = $var; $this->repeated_float = $var;
} }
/**
* <code>repeated double repeated_double = 101 [packed = false];</code>
*/
public function getRepeatedDouble() public function getRepeatedDouble()
{ {
return $this->repeated_double; return $this->repeated_double;
} }
/**
* <code>repeated double repeated_double = 101 [packed = false];</code>
*/
public function setRepeatedDouble(&$var) public function setRepeatedDouble(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::DOUBLE); GPBUtil::checkRepeatedField($var, GPBType::DOUBLE);
$this->repeated_double = $var; $this->repeated_double = $var;
} }
/**
* <code>repeated bool repeated_bool = 102 [packed = false];</code>
*/
public function getRepeatedBool() public function getRepeatedBool()
{ {
return $this->repeated_bool; return $this->repeated_bool;
} }
/**
* <code>repeated bool repeated_bool = 102 [packed = false];</code>
*/
public function setRepeatedBool(&$var) public function setRepeatedBool(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::BOOL); GPBUtil::checkRepeatedField($var, GPBType::BOOL);
$this->repeated_bool = $var; $this->repeated_bool = $var;
} }
/**
* <code>repeated .foo.TestEnum repeated_enum = 103 [packed = false];</code>
*/
public function getRepeatedEnum() public function getRepeatedEnum()
{ {
return $this->repeated_enum; return $this->repeated_enum;
} }
/**
* <code>repeated .foo.TestEnum repeated_enum = 103 [packed = false];</code>
*/
public function setRepeatedEnum(&$var) public function setRepeatedEnum(&$var)
{ {
GPBUtil::checkRepeatedField($var, GPBType::ENUM, Foo\TestEnum::class); GPBUtil::checkRepeatedField($var, GPBType::ENUM, Foo\TestEnum::class);
...@@ -1213,16 +2111,58 @@ class TestUnpackedMessage extends \Google\Protobuf\Internal\Message ...@@ -1213,16 +2111,58 @@ class TestUnpackedMessage extends \Google\Protobuf\Internal\Message
} }
/**
* <pre>
* /&#42;*&#47;&#64;&lt;&gt;&amp;&#92;{
* </pre>
*
* Protobuf type <code>foo.TestPhpDoc</code>
*/
class TestPhpDoc extends \Google\Protobuf\Internal\Message
{
/**
* <code>optional int32 a = 1;</code>
*/
private $a = 0;
/**
* <code>optional int32 a = 1;</code>
*/
public function getA()
{
return $this->a;
}
/**
* <code>optional int32 a = 1;</code>
*/
public function setA($var)
{
GPBUtil::checkInt32($var);
$this->a = $var;
}
}
/**
* Protobuf enum <code>foo.TestEnum</code>
*/
class TestEnum class TestEnum
{ {
/**
* <code>ZERO = 0;</code>
*/
const ZERO = 0; const ZERO = 0;
/**
* <code>ONE = 1;</code>
*/
const ONE = 1; const ONE = 1;
} }
$pool = DescriptorPool::getGeneratedPool(); $pool = DescriptorPool::getGeneratedPool();
$pool->internalAddGeneratedFile(hex2bin( $pool->internalAddGeneratedFile(hex2bin(
"0a83250a0a746573742e70726f746f1203666f6f1a12746573745f696e63" . "0a9c250a0a746573742e70726f746f1203666f6f1a12746573745f696e63" .
"6c7564652e70726f746f22be1d0a0b546573744d65737361676512160a0e" . "6c7564652e70726f746f22be1d0a0b546573744d65737361676512160a0e" .
"6f7074696f6e616c5f696e74333218012001280512160a0e6f7074696f6e" . "6f7074696f6e616c5f696e74333218012001280512160a0e6f7074696f6e" .
"616c5f696e74363418022001280312170a0f6f7074696f6e616c5f75696e" . "616c5f696e74363418022001280312170a0f6f7074696f6e616c5f75696e" .
...@@ -1378,8 +2318,8 @@ $pool->internalAddGeneratedFile(hex2bin( ...@@ -1378,8 +2318,8 @@ $pool->internalAddGeneratedFile(hex2bin(
"666c6f617418642003280242021000121b0a0f72657065617465645f646f" . "666c6f617418642003280242021000121b0a0f72657065617465645f646f" .
"75626c651865200328014202100012190a0d72657065617465645f626f6f" . "75626c651865200328014202100012190a0d72657065617465645f626f6f" .
"6c1866200328084202100012280a0d72657065617465645f656e756d1867" . "6c1866200328084202100012280a0d72657065617465645f656e756d1867" .
"2003280e320d2e666f6f2e54657374456e756d420210002a1d0a08546573" . "2003280e320d2e666f6f2e54657374456e756d4202100022170a0a546573" .
"74456e756d12080a045a45524f100012070a034f4e451001620670726f74" . "74506870446f6312090a01611801200128052a1d0a0854657374456e756d" .
"6f33" "12080a045a45524f100012070a034f4e451001620670726f746f33"
)); ));
...@@ -134,3 +134,8 @@ message TestUnpackedMessage { ...@@ -134,3 +134,8 @@ message TestUnpackedMessage {
repeated bool repeated_bool = 102 [packed = false]; repeated bool repeated_bool = 102 [packed = false];
repeated TestEnum repeated_enum = 103 [packed = false]; repeated TestEnum repeated_enum = 103 [packed = false];
} }
// /**/@<>&\{
message TestPhpDoc {
int32 a = 1;
}
...@@ -9,15 +9,27 @@ use Google\Protobuf\Internal\GPBType; ...@@ -9,15 +9,27 @@ use Google\Protobuf\Internal\GPBType;
use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil; use Google\Protobuf\Internal\GPBUtil;
/**
* Protobuf type <code>bar.TestInclude</code>
*/
class TestInclude extends \Google\Protobuf\Internal\Message class TestInclude extends \Google\Protobuf\Internal\Message
{ {
/**
* <code>optional int32 a = 1;</code>
*/
private $a = 0; private $a = 0;
/**
* <code>optional int32 a = 1;</code>
*/
public function getA() public function getA()
{ {
return $this->a; return $this->a;
} }
/**
* <code>optional int32 a = 1;</code>
*/
public function setA($var) public function setA($var)
{ {
GPBUtil::checkInt32($var); GPBUtil::checkInt32($var);
......
...@@ -52,25 +52,28 @@ namespace php { ...@@ -52,25 +52,28 @@ namespace php {
// Forward decls. // Forward decls.
std::string PhpName(const std::string& full_name, bool is_descriptor); std::string PhpName(const std::string& full_name, bool is_descriptor);
std::string DefaultForField(google::protobuf::FieldDescriptor* field); std::string DefaultForField(FieldDescriptor* field);
std::string IntToString(int32 value); std::string IntToString(int32 value);
std::string GeneratedFileName(const std::string& proto_file, std::string GeneratedFileName(const std::string& proto_file,
bool is_descriptor); bool is_descriptor);
std::string LabelForField(google::protobuf::FieldDescriptor* field); std::string LabelForField(FieldDescriptor* field);
std::string TypeName(google::protobuf::FieldDescriptor* field); std::string TypeName(FieldDescriptor* field);
std::string UnderscoresToCamelCase(const string& name, bool cap_first_letter); std::string UnderscoresToCamelCase(const string& name, bool cap_first_letter);
std::string EscapeDollor(const string& to_escape); std::string EscapeDollor(const string& to_escape);
std::string BinaryToHex(const string& binary); std::string BinaryToHex(const string& binary);
void GenerateMessage(const string& name_prefix, void GenerateMessage(const string& name_prefix, const Descriptor* message,
const google::protobuf::Descriptor* message, bool is_descriptor, io::Printer* printer);
bool is_descriptor, void GenerateEnum(const EnumDescriptor* en, io::Printer* printer);
google::protobuf::io::Printer* printer); void Indent(io::Printer* printer);
void GenerateEnum(const google::protobuf::EnumDescriptor* en, void Outdent(io::Printer* printer);
google::protobuf::io::Printer* printer); void GenerateMessageDocComment(io::Printer* printer, const Descriptor* message);
void Indent(google::protobuf::io::Printer* printer); void GenerateFieldDocComment(io::Printer* printer,
void Outdent(google::protobuf::io::Printer* printer); const FieldDescriptor* field);
void GenerateEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_);
std::string MessagePrefix(const google::protobuf::Descriptor* message) { void GenerateEnumValueDocComment(io::Printer* printer,
const EnumValueDescriptor* value);
std::string MessagePrefix(const Descriptor* message) {
// Empty cannot be php class name. // Empty cannot be php class name.
if (message->name() == "Empty" && if (message->name() == "Empty" &&
message->file()->package() == "google.protobuf") { message->file()->package() == "google.protobuf") {
...@@ -80,10 +83,9 @@ std::string MessagePrefix(const google::protobuf::Descriptor* message) { ...@@ -80,10 +83,9 @@ std::string MessagePrefix(const google::protobuf::Descriptor* message) {
} }
} }
std::string MessageName(const google::protobuf::Descriptor* message, std::string MessageName(const Descriptor* message, bool is_descriptor) {
bool is_descriptor) {
string message_name = message->name(); string message_name = message->name();
const google::protobuf::Descriptor* descriptor = message->containing_type(); const Descriptor* descriptor = message->containing_type();
while (descriptor != NULL) { while (descriptor != NULL) {
message_name = descriptor->name() + '_' + message_name; message_name = descriptor->name() + '_' + message_name;
descriptor = descriptor->containing_type(); descriptor = descriptor->containing_type();
...@@ -94,8 +96,7 @@ std::string MessageName(const google::protobuf::Descriptor* message, ...@@ -94,8 +96,7 @@ std::string MessageName(const google::protobuf::Descriptor* message,
message_name; message_name;
} }
std::string MessageFullName(const google::protobuf::Descriptor* message, std::string MessageFullName(const Descriptor* message, bool is_descriptor) {
bool is_descriptor) {
if (is_descriptor) { if (is_descriptor) {
return StringReplace(message->full_name(), return StringReplace(message->full_name(),
"google.protobuf", "google.protobuf",
...@@ -105,8 +106,7 @@ std::string MessageFullName(const google::protobuf::Descriptor* message, ...@@ -105,8 +106,7 @@ std::string MessageFullName(const google::protobuf::Descriptor* message,
} }
} }
std::string EnumFullName(const google::protobuf::EnumDescriptor* envm, std::string EnumFullName(const EnumDescriptor* envm, bool is_descriptor) {
bool is_descriptor) {
if (is_descriptor) { if (is_descriptor) {
return StringReplace(envm->full_name(), return StringReplace(envm->full_name(),
"google.protobuf", "google.protobuf",
...@@ -116,9 +116,9 @@ std::string EnumFullName(const google::protobuf::EnumDescriptor* envm, ...@@ -116,9 +116,9 @@ std::string EnumFullName(const google::protobuf::EnumDescriptor* envm,
} }
} }
std::string EnumClassName(const google::protobuf::EnumDescriptor* envm) { std::string EnumClassName(const EnumDescriptor* envm) {
string enum_class_name = envm->name(); string enum_class_name = envm->name();
const google::protobuf::Descriptor* descriptor = envm->containing_type(); const Descriptor* descriptor = envm->containing_type();
while (descriptor != NULL) { while (descriptor != NULL) {
enum_class_name = descriptor->name() + '_' + enum_class_name; enum_class_name = descriptor->name() + '_' + enum_class_name;
descriptor = descriptor->containing_type(); descriptor = descriptor->containing_type();
...@@ -126,8 +126,7 @@ std::string EnumClassName(const google::protobuf::EnumDescriptor* envm) { ...@@ -126,8 +126,7 @@ std::string EnumClassName(const google::protobuf::EnumDescriptor* envm) {
return enum_class_name; return enum_class_name;
} }
std::string EnumName(const google::protobuf::EnumDescriptor* envm, std::string EnumName(const EnumDescriptor* envm, bool is_descriptor) {
bool is_descriptor) {
string enum_name = EnumClassName(envm); string enum_name = EnumClassName(envm);
return PhpName(envm->file()->package(), is_descriptor) + '\\' + enum_name; return PhpName(envm->file()->package(), is_descriptor) + '\\' + enum_name;
} }
...@@ -154,7 +153,7 @@ std::string PhpName(const std::string& full_name, bool is_descriptor) { ...@@ -154,7 +153,7 @@ std::string PhpName(const std::string& full_name, bool is_descriptor) {
return result; return result;
} }
std::string DefaultForField(const google::protobuf::FieldDescriptor* field) { std::string DefaultForField(const FieldDescriptor* field) {
switch (field->type()) { switch (field->type()) {
case FieldDescriptor::TYPE_INT32: case FieldDescriptor::TYPE_INT32:
case FieldDescriptor::TYPE_INT64: case FieldDescriptor::TYPE_INT64:
...@@ -194,7 +193,7 @@ std::string IntToString(int32 value) { ...@@ -194,7 +193,7 @@ std::string IntToString(int32 value) {
return os.str(); return os.str();
} }
std::string LabelForField(const google::protobuf::FieldDescriptor* field) { std::string LabelForField(const FieldDescriptor* field) {
switch (field->label()) { switch (field->label()) {
case FieldDescriptor::LABEL_OPTIONAL: return "optional"; case FieldDescriptor::LABEL_OPTIONAL: return "optional";
case FieldDescriptor::LABEL_REQUIRED: return "required"; case FieldDescriptor::LABEL_REQUIRED: return "required";
...@@ -203,7 +202,7 @@ std::string LabelForField(const google::protobuf::FieldDescriptor* field) { ...@@ -203,7 +202,7 @@ std::string LabelForField(const google::protobuf::FieldDescriptor* field) {
} }
} }
std::string TypeName(const google::protobuf::FieldDescriptor* field) { std::string TypeName(const FieldDescriptor* field) {
switch (field->type()) { switch (field->type()) {
case FieldDescriptor::TYPE_INT32: return "int32"; case FieldDescriptor::TYPE_INT32: return "int32";
case FieldDescriptor::TYPE_INT64: return "int64"; case FieldDescriptor::TYPE_INT64: return "int64";
...@@ -228,7 +227,7 @@ std::string TypeName(const google::protobuf::FieldDescriptor* field) { ...@@ -228,7 +227,7 @@ std::string TypeName(const google::protobuf::FieldDescriptor* field) {
} }
std::string EnumOrMessageSuffix( std::string EnumOrMessageSuffix(
const google::protobuf::FieldDescriptor* field, bool is_descriptor) { const FieldDescriptor* field, bool is_descriptor) {
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
return ", '" + MessageFullName(field->message_type(), is_descriptor) + "'"; return ", '" + MessageFullName(field->message_type(), is_descriptor) + "'";
} }
...@@ -299,74 +298,77 @@ std::string BinaryToHex(const string& src) { ...@@ -299,74 +298,77 @@ std::string BinaryToHex(const string& src) {
return dest; return dest;
} }
void Indent(google::protobuf::io::Printer* printer) { void Indent(io::Printer* printer) {
printer->Indent(); printer->Indent();
printer->Indent(); printer->Indent();
} }
void Outdent(google::protobuf::io::Printer* printer) { void Outdent(io::Printer* printer) {
printer->Outdent(); printer->Outdent();
printer->Outdent(); printer->Outdent();
} }
void GenerateField(const google::protobuf::FieldDescriptor* field, void GenerateField(const FieldDescriptor* field, io::Printer* printer,
google::protobuf::io::Printer* printer, bool is_descriptor) { bool is_descriptor) {
if (field->is_repeated()) { if (field->is_repeated()) {
GenerateFieldDocComment(printer, field);
printer->Print( printer->Print(
"private $@name@;\n", "private $^name^;\n",
"name", field->name()); "name", field->name());
} else if (field->containing_oneof()) { } else if (field->containing_oneof()) {
// Oneof fields are handled by GenerateOneofField. // Oneof fields are handled by GenerateOneofField.
return; return;
} else { } else {
GenerateFieldDocComment(printer, field);
printer->Print( printer->Print(
"private $@name@ = @default@;\n", "private $^name^ = ^default^;\n",
"name", field->name(), "name", field->name(),
"default", DefaultForField(field)); "default", DefaultForField(field));
} }
if (is_descriptor) { if (is_descriptor) {
printer->Print( printer->Print(
"private $has_@name@ = false;\n", "private $has_^name^ = false;\n",
"name", field->name()); "name", field->name());
} }
} }
void GenerateOneofField(const google::protobuf::OneofDescriptor* oneof, void GenerateOneofField(const OneofDescriptor* oneof, io::Printer* printer) {
google::protobuf::io::Printer* printer) {
// Oneof property needs to be protected in order to be accessed by parent // Oneof property needs to be protected in order to be accessed by parent
// class in implementation. // class in implementation.
printer->Print( printer->Print(
"protected $@name@;\n", "protected $^name^;\n",
"name", oneof->name()); "name", oneof->name());
} }
void GenerateFieldAccessor(const google::protobuf::FieldDescriptor* field, void GenerateFieldAccessor(const FieldDescriptor* field, bool is_descriptor,
bool is_descriptor, io::Printer* printer) {
google::protobuf::io::Printer* printer) {
const OneofDescriptor* oneof = field->containing_oneof(); const OneofDescriptor* oneof = field->containing_oneof();
// Generate getter. // Generate getter.
if (oneof != NULL) { if (oneof != NULL) {
GenerateFieldDocComment(printer, field);
printer->Print( printer->Print(
"public function get@camel_name@()\n" "public function get^camel_name^()\n"
"{\n" "{\n"
" return $this->readOneof(@number@);\n" " return $this->readOneof(^number^);\n"
"}\n\n", "}\n\n",
"camel_name", UnderscoresToCamelCase(field->name(), true), "camel_name", UnderscoresToCamelCase(field->name(), true),
"number", IntToString(field->number())); "number", IntToString(field->number()));
} else { } else {
GenerateFieldDocComment(printer, field);
printer->Print( printer->Print(
"public function get@camel_name@()\n" "public function get^camel_name^()\n"
"{\n" "{\n"
" return $this->@name@;\n" " return $this->^name^;\n"
"}\n\n", "}\n\n",
"camel_name", UnderscoresToCamelCase(field->name(), true), "name", "camel_name", UnderscoresToCamelCase(field->name(), true), "name",
field->name()); field->name());
} }
// Generate setter. // Generate setter.
GenerateFieldDocComment(printer, field);
printer->Print( printer->Print(
"public function set@camel_name@(@var@)\n" "public function set^camel_name^(^var^)\n"
"{\n", "{\n",
"camel_name", UnderscoresToCamelCase(field->name(), true), "camel_name", UnderscoresToCamelCase(field->name(), true),
"var", (field->is_repeated() || "var", (field->is_repeated() ||
...@@ -379,16 +381,16 @@ void GenerateFieldAccessor(const google::protobuf::FieldDescriptor* field, ...@@ -379,16 +381,16 @@ void GenerateFieldAccessor(const google::protobuf::FieldDescriptor* field,
if (field->is_map()) { if (field->is_map()) {
} else if (field->is_repeated()) { } else if (field->is_repeated()) {
printer->Print( printer->Print(
"GPBUtil::checkRepeatedField($var, GPBType::@type@", "GPBUtil::checkRepeatedField($var, GPBType::^type^",
"type", ToUpper(field->type_name())); "type", ToUpper(field->type_name()));
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
printer->Print( printer->Print(
", \\@class_name@);\n", ", \\^class_name^);\n",
"class_name", "class_name",
MessageName(field->message_type(), is_descriptor) + "::class"); MessageName(field->message_type(), is_descriptor) + "::class");
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) { } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) {
printer->Print( printer->Print(
", @class_name@);\n", ", ^class_name^);\n",
"class_name", "class_name",
EnumName(field->enum_type(), is_descriptor) + "::class"); EnumName(field->enum_type(), is_descriptor) + "::class");
} else { } else {
...@@ -396,37 +398,37 @@ void GenerateFieldAccessor(const google::protobuf::FieldDescriptor* field, ...@@ -396,37 +398,37 @@ void GenerateFieldAccessor(const google::protobuf::FieldDescriptor* field,
} }
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
printer->Print( printer->Print(
"GPBUtil::checkMessage($var, \\@class_name@::class);\n", "GPBUtil::checkMessage($var, \\^class_name^::class);\n",
"class_name", MessageName(field->message_type(), is_descriptor)); "class_name", MessageName(field->message_type(), is_descriptor));
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) { } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) {
printer->Print( printer->Print(
"GPBUtil::checkEnum($var, \\@class_name@::class);\n", "GPBUtil::checkEnum($var, \\^class_name^::class);\n",
"class_name", EnumName(field->enum_type(), is_descriptor)); "class_name", EnumName(field->enum_type(), is_descriptor));
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING) { } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING) {
printer->Print( printer->Print(
"GPBUtil::checkString($var, @utf8@);\n", "GPBUtil::checkString($var, ^utf8^);\n",
"utf8", "utf8",
field->type() == FieldDescriptor::TYPE_STRING ? "True": "False"); field->type() == FieldDescriptor::TYPE_STRING ? "True": "False");
} else { } else {
printer->Print( printer->Print(
"GPBUtil::check@type@($var);\n", "GPBUtil::check^type^($var);\n",
"type", UnderscoresToCamelCase(field->cpp_type_name(), true)); "type", UnderscoresToCamelCase(field->cpp_type_name(), true));
} }
if (oneof != NULL) { if (oneof != NULL) {
printer->Print( printer->Print(
"$this->writeOneof(@number@, $var);\n", "$this->writeOneof(^number^, $var);\n",
"number", IntToString(field->number())); "number", IntToString(field->number()));
} else { } else {
printer->Print( printer->Print(
"$this->@name@ = $var;\n", "$this->^name^ = $var;\n",
"name", field->name()); "name", field->name());
} }
// Set has bit for proto2 only. // Set has bit for proto2 only.
if (is_descriptor) { if (is_descriptor) {
printer->Print( printer->Print(
"$this->has_@field_name@ = true;\n", "$this->has_^field_name^ = true;\n",
"field_name", field->name()); "field_name", field->name());
} }
...@@ -438,39 +440,36 @@ void GenerateFieldAccessor(const google::protobuf::FieldDescriptor* field, ...@@ -438,39 +440,36 @@ void GenerateFieldAccessor(const google::protobuf::FieldDescriptor* field,
// Generate has method for proto2 only. // Generate has method for proto2 only.
if (is_descriptor) { if (is_descriptor) {
printer->Print( printer->Print(
"public function has@camel_name@()\n" "public function has^camel_name^()\n"
"{\n" "{\n"
" return $this->has_@field_name@;\n" " return $this->has_^field_name^;\n"
"}\n\n", "}\n\n",
"camel_name", UnderscoresToCamelCase(field->name(), true), "camel_name", UnderscoresToCamelCase(field->name(), true),
"field_name", field->name()); "field_name", field->name());
} }
} }
void GenerateRepeatedFieldDecode( void GenerateRepeatedFieldDecode(const FieldDescriptor* field,
const google::protobuf::FieldDescriptor* field, io::Printer* printer) {
google::protobuf::io::Printer* printer) {
printer->Print( printer->Print(
"if ($input->read@cap_wire_type@($var)) return False;\n" "if ($input->read^cap_wire_type^($var)) return False;\n"
"$this->get@cap_field_name@() []= $var;\n", "$this->get^cap_field_name^() []= $var;\n",
"cap_field_name", UnderscoresToCamelCase(field->name(), true), "cap_field_name", UnderscoresToCamelCase(field->name(), true),
"cap_wire_type", UnderscoresToCamelCase(field->type_name(), true)); "cap_wire_type", UnderscoresToCamelCase(field->type_name(), true));
} }
void GeneratePrimitiveFieldDecode( void GeneratePrimitiveFieldDecode(const FieldDescriptor* field,
const google::protobuf::FieldDescriptor* field, io::Printer* printer) {
google::protobuf::io::Printer* printer) {
printer->Print( printer->Print(
"if ($input->read@cap_wire_type@($var)) return False;\n" "if ($input->read^cap_wire_type^($var)) return False;\n"
"$this->set@cap_field_name@($var);\n", "$this->set^cap_field_name^($var);\n",
"cap_field_name", UnderscoresToCamelCase(field->name(), true), "cap_field_name", UnderscoresToCamelCase(field->name(), true),
"cap_wire_type", UnderscoresToCamelCase(field->type_name(), true)); "cap_wire_type", UnderscoresToCamelCase(field->type_name(), true));
} }
void GenerateFieldDecode(const google::protobuf::FieldDescriptor* field, void GenerateFieldDecode(const FieldDescriptor* field, io::Printer* printer) {
google::protobuf::io::Printer* printer) {
printer->Print( printer->Print(
"case @number@:\n", "case ^number^:\n",
"number", IntToString(field->number())); "number", IntToString(field->number()));
Indent(printer); Indent(printer);
...@@ -485,23 +484,23 @@ void GenerateFieldDecode(const google::protobuf::FieldDescriptor* field, ...@@ -485,23 +484,23 @@ void GenerateFieldDecode(const google::protobuf::FieldDescriptor* field,
Outdent(printer); Outdent(printer);
} }
void GenerateMessage(const string& name_prefix, void GenerateMessage(const string& name_prefix, const Descriptor* message,
const google::protobuf::Descriptor* message, bool is_descriptor, io::Printer* printer) {
bool is_descriptor,
google::protobuf::io::Printer* printer) {
// Don't generate MapEntry messages -- we use the PHP extension's native // Don't generate MapEntry messages -- we use the PHP extension's native
// support for map fields instead. // support for map fields instead.
if (message->options().map_entry()) { if (message->options().map_entry()) {
return; return;
} }
GenerateMessageDocComment(printer, message);
string message_name = string message_name =
name_prefix.empty() name_prefix.empty()
? message->name() ? message->name()
: name_prefix + "_" + MessagePrefix(message) + message->name(); : name_prefix + "_" + MessagePrefix(message) + message->name();
printer->Print( printer->Print(
"class @name@ extends \\Google\\Protobuf\\Internal\\Message\n" "class ^name^ extends \\Google\\Protobuf\\Internal\\Message\n"
"{\n", "{\n",
"name", message_name); "name", message_name);
Indent(printer); Indent(printer);
...@@ -523,11 +522,11 @@ void GenerateMessage(const string& name_prefix, ...@@ -523,11 +522,11 @@ void GenerateMessage(const string& name_prefix,
GenerateFieldAccessor(field, is_descriptor, printer); GenerateFieldAccessor(field, is_descriptor, printer);
} }
for (int i = 0; i < message->oneof_decl_count(); i++) { for (int i = 0; i < message->oneof_decl_count(); i++) {
const google::protobuf::OneofDescriptor* oneof = message->oneof_decl(i); const OneofDescriptor* oneof = message->oneof_decl(i);
printer->Print( printer->Print(
"public function get@camel_name@()\n" "public function get^camel_name^()\n"
"{\n" "{\n"
" return $this->@name@;\n" " return $this->^name^;\n"
"}\n\n", "}\n\n",
"camel_name", UnderscoresToCamelCase(oneof->name(), true), "name", "camel_name", UnderscoresToCamelCase(oneof->name(), true), "name",
oneof->name()); oneof->name());
...@@ -546,11 +545,10 @@ void GenerateMessage(const string& name_prefix, ...@@ -546,11 +545,10 @@ void GenerateMessage(const string& name_prefix,
} }
} }
void GenerateEnumToPool(const google::protobuf::EnumDescriptor* en, void GenerateEnumToPool(const EnumDescriptor* en, bool is_descriptor,
bool is_descriptor, io::Printer* printer) {
google::protobuf::io::Printer* printer) {
printer->Print( printer->Print(
"$pool->addEnum('@name@', @class_name@::class)\n", "$pool->addEnum('^name^', ^class_name^::class)\n",
"name", EnumFullName(en, is_descriptor), "name", EnumFullName(en, is_descriptor),
"class_name", en->name()); "class_name", en->name());
Indent(printer); Indent(printer);
...@@ -558,7 +556,7 @@ void GenerateEnumToPool(const google::protobuf::EnumDescriptor* en, ...@@ -558,7 +556,7 @@ void GenerateEnumToPool(const google::protobuf::EnumDescriptor* en,
for (int i = 0; i < en->value_count(); i++) { for (int i = 0; i < en->value_count(); i++) {
const EnumValueDescriptor* value = en->value(i); const EnumValueDescriptor* value = en->value(i);
printer->Print( printer->Print(
"->value(\"@name@\", @number@)\n", "->value(\"^name^\", ^number^)\n",
"name", value->name(), "name", value->name(),
"number", IntToString(value->number())); "number", IntToString(value->number()));
} }
...@@ -566,10 +564,8 @@ void GenerateEnumToPool(const google::protobuf::EnumDescriptor* en, ...@@ -566,10 +564,8 @@ void GenerateEnumToPool(const google::protobuf::EnumDescriptor* en,
Outdent(printer); Outdent(printer);
} }
void GenerateMessageToPool(const string& name_prefix, void GenerateMessageToPool(const string& name_prefix, const Descriptor* message,
const google::protobuf::Descriptor* message, bool is_descriptor, io::Printer* printer) {
bool is_descriptor,
google::protobuf::io::Printer* printer) {
// Don't generate MapEntry messages -- we use the PHP extension's native // Don't generate MapEntry messages -- we use the PHP extension's native
// support for map fields instead. // support for map fields instead.
if (message->options().map_entry()) { if (message->options().map_entry()) {
...@@ -579,7 +575,7 @@ void GenerateMessageToPool(const string& name_prefix, ...@@ -579,7 +575,7 @@ void GenerateMessageToPool(const string& name_prefix,
message->name() : name_prefix + "_" + message->name(); message->name() : name_prefix + "_" + message->name();
printer->Print( printer->Print(
"$pool->addMessage('@message@', @class_name@::class)\n", "$pool->addMessage('^message^', ^class_name^::class)\n",
"message", MessageFullName(message, is_descriptor), "message", MessageFullName(message, is_descriptor),
"class_name", class_name); "class_name", class_name);
...@@ -593,8 +589,8 @@ void GenerateMessageToPool(const string& name_prefix, ...@@ -593,8 +589,8 @@ void GenerateMessageToPool(const string& name_prefix,
const FieldDescriptor* val = const FieldDescriptor* val =
field->message_type()->FindFieldByName("value"); field->message_type()->FindFieldByName("value");
printer->Print( printer->Print(
"->map('@field@', GPBType::@key@, " "->map('^field^', GPBType::^key^, "
"GPBType::@value@, @number@@other@)\n", "GPBType::^value^, ^number^^other^)\n",
"field", field->name(), "field", field->name(),
"key", ToUpper(key->type_name()), "key", ToUpper(key->type_name()),
"value", ToUpper(val->type_name()), "value", ToUpper(val->type_name()),
...@@ -602,7 +598,7 @@ void GenerateMessageToPool(const string& name_prefix, ...@@ -602,7 +598,7 @@ void GenerateMessageToPool(const string& name_prefix,
"other", EnumOrMessageSuffix(val, is_descriptor)); "other", EnumOrMessageSuffix(val, is_descriptor));
} else if (!field->containing_oneof()) { } else if (!field->containing_oneof()) {
printer->Print( printer->Print(
"->@label@('@field@', GPBType::@type@, @number@@other@)\n", "->^label^('^field^', GPBType::^type^, ^number^^other^)\n",
"field", field->name(), "field", field->name(),
"label", LabelForField(field), "label", LabelForField(field),
"type", ToUpper(field->type_name()), "type", ToUpper(field->type_name()),
...@@ -614,13 +610,13 @@ void GenerateMessageToPool(const string& name_prefix, ...@@ -614,13 +610,13 @@ void GenerateMessageToPool(const string& name_prefix,
// oneofs. // oneofs.
for (int i = 0; i < message->oneof_decl_count(); i++) { for (int i = 0; i < message->oneof_decl_count(); i++) {
const OneofDescriptor* oneof = message->oneof_decl(i); const OneofDescriptor* oneof = message->oneof_decl(i);
printer->Print("->oneof(@name@)\n", printer->Print("->oneof(^name^)\n",
"name", oneof->name()); "name", oneof->name());
Indent(printer); Indent(printer);
for (int index = 0; index < oneof->field_count(); index++) { for (int index = 0; index < oneof->field_count(); index++) {
const FieldDescriptor* field = oneof->field(index); const FieldDescriptor* field = oneof->field(index);
printer->Print( printer->Print(
"->value('@field@', GPBType::@type@, @number@@other@)\n", "->value('^field^', GPBType::^type^, ^number^^other^)\n",
"field", field->name(), "field", field->name(),
"type", ToUpper(field->type_name()), "type", ToUpper(field->type_name()),
"number", SimpleItoa(field->number()), "number", SimpleItoa(field->number()),
...@@ -647,9 +643,8 @@ void GenerateMessageToPool(const string& name_prefix, ...@@ -647,9 +643,8 @@ void GenerateMessageToPool(const string& name_prefix,
} }
} }
void GenerateAddFileToPool(const google::protobuf::FileDescriptor* file, void GenerateAddFileToPool(const FileDescriptor* file, bool is_descriptor,
bool is_descriptor, io::Printer* printer) {
google::protobuf::io::Printer* printer) {
if (is_descriptor) { if (is_descriptor) {
printer->Print("$pool = DescriptorPool::getGeneratedPool();\n\n"); printer->Print("$pool = DescriptorPool::getGeneratedPool();\n\n");
...@@ -679,7 +674,7 @@ void GenerateAddFileToPool(const google::protobuf::FileDescriptor* file, ...@@ -679,7 +674,7 @@ void GenerateAddFileToPool(const google::protobuf::FileDescriptor* file,
static const int kBytesPerLine = 30; static const int kBytesPerLine = 30;
for (int i = 0; i < files_data.size(); i += kBytesPerLine) { for (int i = 0; i < files_data.size(); i += kBytesPerLine) {
printer->Print( printer->Print(
"\"@data@\"@dot@\n", "\"^data^\"^dot^\n",
"data", BinaryToHex(files_data.substr(i, kBytesPerLine)), "data", BinaryToHex(files_data.substr(i, kBytesPerLine)),
"dot", i + kBytesPerLine < files_data.size() ? " ." : ""); "dot", i + kBytesPerLine < files_data.size() ? " ." : "");
} }
...@@ -691,17 +686,18 @@ void GenerateAddFileToPool(const google::protobuf::FileDescriptor* file, ...@@ -691,17 +686,18 @@ void GenerateAddFileToPool(const google::protobuf::FileDescriptor* file,
} }
void GenerateEnum(const google::protobuf::EnumDescriptor* en, void GenerateEnum(const EnumDescriptor* en, io::Printer* printer) {
google::protobuf::io::Printer* printer) { GenerateEnumDocComment(printer, en);
printer->Print( printer->Print(
"class @name@\n" "class ^name^\n"
"{\n", "{\n",
"name", EnumClassName(en)); "name", EnumClassName(en));
Indent(printer); Indent(printer);
for (int i = 0; i < en->value_count(); i++) { for (int i = 0; i < en->value_count(); i++) {
const EnumValueDescriptor* value = en->value(i); const EnumValueDescriptor* value = en->value(i);
printer->Print("const @name@ = @number@;\n", GenerateEnumValueDocComment(printer, value);
printer->Print("const ^name^ = ^number^;\n",
"name", value->name(), "name", value->name(),
"number", IntToString(value->number())); "number", IntToString(value->number()));
} }
...@@ -709,8 +705,7 @@ void GenerateEnum(const google::protobuf::EnumDescriptor* en, ...@@ -709,8 +705,7 @@ void GenerateEnum(const google::protobuf::EnumDescriptor* en,
printer->Print("}\n\n"); printer->Print("}\n\n");
} }
void GenerateUseDeclaration(bool is_descriptor, void GenerateUseDeclaration(bool is_descriptor, io::Printer* printer) {
google::protobuf::io::Printer* printer) {
if (!is_descriptor) { if (!is_descriptor) {
printer->Print( printer->Print(
"use Google\\Protobuf\\Internal\\DescriptorPool;\n" "use Google\\Protobuf\\Internal\\DescriptorPool;\n"
...@@ -728,22 +723,22 @@ void GenerateUseDeclaration(bool is_descriptor, ...@@ -728,22 +723,22 @@ void GenerateUseDeclaration(bool is_descriptor,
} }
} }
void GenerateFile(const google::protobuf::FileDescriptor* file, void GenerateFile(const FileDescriptor* file, bool is_descriptor,
bool is_descriptor, google::protobuf::io::Printer* printer) { io::Printer* printer) {
printer->Print( printer->Print(
"<?php\n" "<?php\n"
"# Generated by the protocol buffer compiler. DO NOT EDIT!\n" "# Generated by the protocol buffer compiler. DO NOT EDIT!\n"
"# source: @filename@\n" "# source: ^filename^\n"
"\n", "\n",
"filename", file->name()); "filename", file->name());
if (!file->package().empty()) { if (!file->package().empty()) {
printer->Print("namespace @name@;\n\n", printer->Print("namespace ^name^;\n\n",
"name", PhpName(file->package(), is_descriptor)); "name", PhpName(file->package(), is_descriptor));
} }
for (int i = 0; i < file->dependency_count(); i++) { for (int i = 0; i < file->dependency_count(); i++) {
const std::string& name = file->dependency(i)->name(); const std::string& name = file->dependency(i)->name();
printer->Print("require_once('@name@');\n", "name", printer->Print("require_once('^name^');\n", "name",
GeneratedFileName(name, is_descriptor)); GeneratedFileName(name, is_descriptor));
} }
...@@ -759,9 +754,167 @@ void GenerateFile(const google::protobuf::FileDescriptor* file, ...@@ -759,9 +754,167 @@ void GenerateFile(const google::protobuf::FileDescriptor* file,
GenerateAddFileToPool(file, is_descriptor, printer); GenerateAddFileToPool(file, is_descriptor, printer);
} }
bool Generator::Generate( static string EscapePhpdoc(const string& input) {
const FileDescriptor* file, string result;
const string& parameter, result.reserve(input.size() * 2);
char prev = '*';
for (string::size_type i = 0; i < input.size(); i++) {
char c = input[i];
switch (c) {
case '*':
// Avoid "/*".
if (prev == '/') {
result.append("&#42;");
} else {
result.push_back(c);
}
break;
case '/':
// Avoid "*/".
if (prev == '*') {
result.append("&#47;");
} else {
result.push_back(c);
}
break;
case '@':
// '@' starts phpdoc tags including the @deprecated tag, which will
// cause a compile-time error if inserted before a declaration that
// does not have a corresponding @Deprecated annotation.
result.append("&#64;");
break;
case '<':
// Avoid interpretation as HTML.
result.append("&lt;");
break;
case '>':
// Avoid interpretation as HTML.
result.append("&gt;");
break;
case '&':
// Avoid interpretation as HTML.
result.append("&amp;");
break;
case '\\':
// Java interprets Unicode escape sequences anywhere!
result.append("&#92;");
break;
default:
result.push_back(c);
break;
}
prev = c;
}
return result;
}
static void GenerateDocCommentBodyForLocation(
io::Printer* printer, const SourceLocation& location) {
string comments = location.leading_comments.empty() ?
location.trailing_comments : location.leading_comments;
if (!comments.empty()) {
// TODO(teboring): Ideally we should parse the comment text as Markdown and
// write it back as HTML, but this requires a Markdown parser. For now
// we just use <pre> to get fixed-width text formatting.
// If the comment itself contains block comment start or end markers,
// HTML-escape them so that they don't accidentally close the doc comment.
comments = EscapePhpdoc(comments);
vector<string> lines = Split(comments, "\n");
while (!lines.empty() && lines.back().empty()) {
lines.pop_back();
}
printer->Print(" * <pre>\n");
for (int i = 0; i < lines.size(); i++) {
// Most lines should start with a space. Watch out for lines that start
// with a /, since putting that right after the leading asterisk will
// close the comment.
if (!lines[i].empty() && lines[i][0] == '/') {
printer->Print(" * ^line^\n", "line", lines[i]);
} else {
printer->Print(" *^line^\n", "line", lines[i]);
}
}
printer->Print(
" * </pre>\n"
" *\n");
}
}
template <typename DescriptorType>
static void GenerateDocCommentBody(
io::Printer* printer, const DescriptorType* descriptor) {
SourceLocation location;
if (descriptor->GetSourceLocation(&location)) {
GenerateDocCommentBodyForLocation(printer, location);
}
}
static string FirstLineOf(const string& value) {
string result = value;
string::size_type pos = result.find_first_of('\n');
if (pos != string::npos) {
result.erase(pos);
}
return result;
}
void GenerateMessageDocComment(io::Printer* printer,
const Descriptor* message) {
printer->Print("/**\n");
GenerateDocCommentBody(printer, message);
printer->Print(
" * Protobuf type <code>^fullname^</code>\n"
" */\n",
"fullname", EscapePhpdoc(message->full_name()));
}
void GenerateFieldDocComment(io::Printer* printer,
const FieldDescriptor* field) {
// In theory we should have slightly different comments for setters, getters,
// etc., but in practice everyone already knows the difference between these
// so it's redundant information.
// We start the comment with the main body based on the comments from the
// .proto file (if present). We then end with the field declaration, e.g.:
// optional string foo = 5;
// If the field is a group, the debug string might end with {.
printer->Print("/**\n");
GenerateDocCommentBody(printer, field);
printer->Print(
" * <code>^def^</code>\n",
"def", EscapePhpdoc(FirstLineOf(field->DebugString())));
printer->Print(" */\n");
}
void GenerateEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_) {
printer->Print("/**\n");
GenerateDocCommentBody(printer, enum_);
printer->Print(
" * Protobuf enum <code>^fullname^</code>\n"
" */\n",
"fullname", EscapePhpdoc(enum_->full_name()));
}
void GenerateEnumValueDocComment(io::Printer* printer,
const EnumValueDescriptor* value) {
printer->Print("/**\n");
GenerateDocCommentBody(printer, value);
printer->Print(
" * <code>^def^</code>\n"
" */\n",
"def", EscapePhpdoc(FirstLineOf(value->DebugString())));
}
bool Generator::Generate(const FileDescriptor* file, const string& parameter,
GeneratorContext* generator_context, GeneratorContext* generator_context,
string* error) const { string* error) const {
bool is_descriptor = parameter == "internal"; bool is_descriptor = parameter == "internal";
...@@ -782,7 +935,7 @@ bool Generator::Generate( ...@@ -782,7 +935,7 @@ bool Generator::Generate(
std::string filename = GeneratedFileName(file->name(), is_descriptor); std::string filename = GeneratedFileName(file->name(), is_descriptor);
scoped_ptr<io::ZeroCopyOutputStream> output( scoped_ptr<io::ZeroCopyOutputStream> output(
generator_context->Open(filename)); generator_context->Open(filename));
io::Printer printer(output.get(), '@'); io::Printer printer(output.get(), '^');
GenerateFile(file, is_descriptor, &printer); GenerateFile(file, is_descriptor, &printer);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment