Exemple #1
0
 /**
  * @ignore
  */
 public function __construct($desc = NULL)
 {
     // MapEntry message is shared by all types of map fields, whose
     // descriptors are different from each other. Thus, we cannot find a
     // specific descriptor from the descriptor pool.
     if (get_class($this) === 'Google\\Protobuf\\Internal\\MapEntry') {
         $this->desc = $desc;
         return;
     }
     $pool = DescriptorPool::getGeneratedPool();
     $this->desc = $pool->getDescriptorByClassName(get_class($this));
     foreach ($this->desc->getField() as $field) {
         $setter = $field->getSetter();
         if ($field->isMap()) {
             $message_type = $field->getMessageType();
             $key_field = $message_type->getFieldByNumber(1);
             $value_field = $message_type->getFieldByNumber(2);
             switch ($value_field->getType()) {
                 case GPBType::MESSAGE:
                 case GPBType::GROUP:
                     $map_field = new MapField($key_field->getType(), $value_field->getType(), $value_field->getMessageType()->getClass());
                     $this->{$setter}($map_field);
                     break;
                 case GPBType::ENUM:
                     $map_field = new MapField($key_field->getType(), $value_field->getType(), $value_field->getEnumType()->getClass());
                     $this->{$setter}($map_field);
                     break;
                 default:
                     $map_field = new MapField($key_field->getType(), $value_field->getType());
                     $this->{$setter}($map_field);
                     break;
             }
         } else {
             if ($field->getLabel() === GPBLabel::REPEATED) {
                 switch ($field->getType()) {
                     case GPBType::MESSAGE:
                     case GPBType::GROUP:
                         $repeated_field = new RepeatedField($field->getType(), $field->getMessageType()->getClass());
                         $this->{$setter}($repeated_field);
                         break;
                     case GPBType::ENUM:
                         $repeated_field = new RepeatedField($field->getType(), $field->getEnumType()->getClass());
                         $this->{$setter}($repeated_field);
                         break;
                     default:
                         $repeated_field = new RepeatedField($field->getType());
                         $this->{$setter}($repeated_field);
                         break;
                 }
             } else {
                 if ($field->getOneofIndex() !== -1) {
                     $oneof = $this->desc->getOneofDecl()[$field->getOneofIndex()];
                     $oneof_name = $oneof->getName();
                     $this->{$oneof_name} = new OneofField($oneof);
                 }
             }
         }
     }
 }
Exemple #2
0
    public function setRepeatedDouble(&$var)
    {
        GPBUtil::checkRepeatedField($var, GPBType::DOUBLE);
        $this->repeated_double = $var;
    }
    public function getRepeatedBool()
    {
        return $this->repeated_bool;
    }
    public function setRepeatedBool(&$var)
    {
        GPBUtil::checkRepeatedField($var, GPBType::BOOL);
        $this->repeated_bool = $var;
    }
    public function getRepeatedEnum()
    {
        return $this->repeated_enum;
    }
    public function setRepeatedEnum(&$var)
    {
        GPBUtil::checkRepeatedField($var, GPBType::ENUM, Foo\TestEnum::class);
        $this->repeated_enum = $var;
    }
}
class TestEnum
{
    const ZERO = 0;
    const ONE = 1;
}
$pool = DescriptorPool::getGeneratedPool();
$pool->internalAddGeneratedFile(hex2bin("0a83250a0a746573742e70726f746f1203666f6f1a12746573745f696e63" . "6c7564652e70726f746f22be1d0a0b546573744d65737361676512160a0e" . "6f7074696f6e616c5f696e74333218012001280512160a0e6f7074696f6e" . "616c5f696e74363418022001280312170a0f6f7074696f6e616c5f75696e" . "74333218032001280d12170a0f6f7074696f6e616c5f75696e7436341804" . "2001280412170a0f6f7074696f6e616c5f73696e74333218052001281112" . "170a0f6f7074696f6e616c5f73696e74363418062001281212180a106f70" . "74696f6e616c5f6669786564333218072001280712180a106f7074696f6e" . "616c5f6669786564363418082001280612190a116f7074696f6e616c5f73" . "6669786564333218092001280f12190a116f7074696f6e616c5f73666978" . "65643634180a2001281012160a0e6f7074696f6e616c5f666c6f6174180b" . "2001280212170a0f6f7074696f6e616c5f646f75626c65180c2001280112" . "150a0d6f7074696f6e616c5f626f6f6c180d2001280812170a0f6f707469" . "6f6e616c5f737472696e67180e2001280912160a0e6f7074696f6e616c5f" . "6279746573180f2001280c12240a0d6f7074696f6e616c5f656e756d1810" . "2001280e320d2e666f6f2e54657374456e756d122e0a106f7074696f6e61" . "6c5f6d65737361676518112001280b32142e666f6f2e546573744d657373" . "6167652e53756212330a196f7074696f6e616c5f696e636c756465645f6d" . "65737361676518122001280b32102e6261722e54657374496e636c756465" . "12230a0972656375727369766518132001280b32102e666f6f2e54657374" . "4d65737361676512160a0e72657065617465645f696e743332181f200328" . "0512160a0e72657065617465645f696e74363418202003280312170a0f72" . "657065617465645f75696e74333218212003280d12170a0f726570656174" . "65645f75696e74363418222003280412170a0f72657065617465645f7369" . "6e74333218232003281112170a0f72657065617465645f73696e74363418" . "242003281212180a1072657065617465645f666978656433321825200328" . "0712180a1072657065617465645f6669786564363418262003280612190a" . "1172657065617465645f736669786564333218272003280f12190a117265" . "7065617465645f736669786564363418282003281012160a0e7265706561" . "7465645f666c6f617418292003280212170a0f72657065617465645f646f" . "75626c65182a2003280112150a0d72657065617465645f626f6f6c182b20" . "03280812170a0f72657065617465645f737472696e67182c200328091216" . "0a0e72657065617465645f6279746573182d2003280c12240a0d72657065" . "617465645f656e756d182e2003280e320d2e666f6f2e54657374456e756d" . "122e0a1072657065617465645f6d657373616765182f2003280b32142e66" . "6f6f2e546573744d6573736167652e537562122c0a127265706561746564" . "5f72656375727369766518302003280b32102e666f6f2e546573744d6573" . "7361676512150a0b6f6e656f665f696e743332183320012805480012150a" . "0b6f6e656f665f696e743634183420012803480012160a0c6f6e656f665f" . "75696e74333218352001280d480012160a0c6f6e656f665f75696e743634" . "183620012804480012160a0c6f6e656f665f73696e74333218372001280d" . "480012160a0c6f6e656f665f73696e743634183820012804480012170a0d" . "6f6e656f665f6669786564333218392001280d480012170a0d6f6e656f66" . "5f66697865643634183a20012804480012180a0e6f6e656f665f73666978" . "65643332183b2001280d480012180a0e6f6e656f665f7366697865643634" . "183c20012804480012160a0c6f6e656f665f646f75626c65183d20012801" . "480012150a0b6f6e656f665f666c6f6174183e20012802480012140a0a6f" . "6e656f665f626f6f6c183f20012808480012160a0c6f6e656f665f737472" . "696e67184020012809480012150a0b6f6e656f665f627974657318412001" . "280c480012230a0a6f6e656f665f656e756d18422001280e320d2e666f6f" . "2e54657374456e756d4800122d0a0d6f6e656f665f6d6573736167651843" . "2001280b32142e666f6f2e546573744d6573736167652e5375624800123c" . "0a0f6d61705f696e7433325f696e74333218472003280b32232e666f6f2e" . "546573744d6573736167652e4d6170496e743332496e743332456e747279" . "123c0a0f6d61705f696e7436345f696e74363418482003280b32232e666f" . "6f2e546573744d6573736167652e4d6170496e743634496e743634456e74" . "727912400a116d61705f75696e7433325f75696e74333218492003280b32" . "252e666f6f2e546573744d6573736167652e4d617055696e74333255696e" . "743332456e74727912400a116d61705f75696e7436345f75696e74363418" . "4a2003280b32252e666f6f2e546573744d6573736167652e4d617055696e" . "74363455696e743634456e74727912400a116d61705f73696e7433325f73" . "696e743332184b2003280b32252e666f6f2e546573744d6573736167652e" . "4d617053696e74333253696e743332456e74727912400a116d61705f7369" . "6e7436345f73696e743634184c2003280b32252e666f6f2e546573744d65" . "73736167652e4d617053696e74363453696e743634456e74727912440a13" . "6d61705f666978656433325f66697865643332184d2003280b32272e666f" . "6f2e546573744d6573736167652e4d617046697865643332466978656433" . "32456e74727912440a136d61705f666978656436345f6669786564363418" . "4e2003280b32272e666f6f2e546573744d6573736167652e4d6170466978" . "6564363446697865643634456e74727912480a156d61705f736669786564" . "33325f7366697865643332184f2003280b32292e666f6f2e546573744d65" . "73736167652e4d617053666978656433325366697865643332456e747279" . "12480a156d61705f73666978656436345f73666978656436341850200328" . "0b32292e666f6f2e546573744d6573736167652e4d617053666978656436" . "345366697865643634456e747279123c0a0f6d61705f696e7433325f666c" . "6f617418512003280b32232e666f6f2e546573744d6573736167652e4d61" . "70496e743332466c6f6174456e747279123e0a106d61705f696e7433325f" . "646f75626c6518522003280b32242e666f6f2e546573744d657373616765" . "2e4d6170496e743332446f75626c65456e74727912380a0d6d61705f626f" . "6f6c5f626f6f6c18532003280b32212e666f6f2e546573744d6573736167" . "652e4d6170426f6f6c426f6f6c456e74727912400a116d61705f73747269" . "6e675f737472696e6718542003280b32252e666f6f2e546573744d657373" . "6167652e4d6170537472696e67537472696e67456e747279123c0a0f6d61" . "705f696e7433325f627974657318552003280b32232e666f6f2e54657374" . "4d6573736167652e4d6170496e7433324279746573456e747279123a0a0e" . "6d61705f696e7433325f656e756d18562003280b32222e666f6f2e546573" . "744d6573736167652e4d6170496e743332456e756d456e74727912400a11" . "6d61705f696e7433325f6d65737361676518572003280b32252e666f6f2e" . "546573744d6573736167652e4d6170496e7433324d657373616765456e74" . "727912390a0d6d61705f72656375727369766518582003280b32222e666f" . "6f2e546573744d6573736167652e4d6170526563757273697665456e7472" . "791a340a124d6170496e743332496e743332456e747279120b0a036b6579" . "180120012805120d0a0576616c75651802200128053a0238011a340a124d" . "6170496e743634496e743634456e747279120b0a036b6579180120012803" . "120d0a0576616c75651802200128033a0238011a360a144d617055696e74" . "333255696e743332456e747279120b0a036b657918012001280d120d0a05" . "76616c756518022001280d3a0238011a360a144d617055696e7436345569" . "6e743634456e747279120b0a036b6579180120012804120d0a0576616c75" . "651802200128043a0238011a360a144d617053696e74333253696e743332" . "456e747279120b0a036b6579180120012811120d0a0576616c7565180220" . "0128113a0238011a360a144d617053696e74363453696e743634456e7472" . "79120b0a036b6579180120012812120d0a0576616c75651802200128123a" . "0238011a380a164d61704669786564333246697865643332456e74727912" . "0b0a036b6579180120012807120d0a0576616c75651802200128073a0238" . "011a380a164d61704669786564363446697865643634456e747279120b0a" . "036b6579180120012806120d0a0576616c75651802200128063a0238011a" . "3a0a184d617053666978656433325366697865643332456e747279120b0a" . "036b657918012001280f120d0a0576616c756518022001280f3a0238011a" . "3a0a184d617053666978656436345366697865643634456e747279120b0a" . "036b6579180120012810120d0a0576616c75651802200128103a0238011a" . "340a124d6170496e743332466c6f6174456e747279120b0a036b65791801" . "20012805120d0a0576616c75651802200128023a0238011a350a134d6170" . "496e743332446f75626c65456e747279120b0a036b657918012001280512" . "0d0a0576616c75651802200128013a0238011a320a104d6170426f6f6c42" . "6f6f6c456e747279120b0a036b6579180120012808120d0a0576616c7565" . "1802200128083a0238011a360a144d6170537472696e67537472696e6745" . "6e747279120b0a036b6579180120012809120d0a0576616c756518022001" . "28093a0238011a340a124d6170496e7433324279746573456e747279120b" . "0a036b6579180120012805120d0a0576616c756518022001280c3a023801" . "1a420a114d6170496e743332456e756d456e747279120b0a036b65791801" . "20012805121c0a0576616c756518022001280e320d2e666f6f2e54657374" . "456e756d3a0238011a4c0a144d6170496e7433324d657373616765456e74" . "7279120b0a036b657918012001280512230a0576616c756518022001280b" . "32142e666f6f2e546573744d6573736167652e5375623a0238011a450a11" . "4d6170526563757273697665456e747279120b0a036b6579180120012805" . "121f0a0576616c756518022001280b32102e666f6f2e546573744d657373" . "6167653a0238011a100a0353756212090a0161180120012805420a0a086d" . "795f6f6e656f6622b7030a11546573745061636b65644d65737361676512" . "1a0a0e72657065617465645f696e743332185a2003280542021001121a0a" . "0e72657065617465645f696e743634185b2003280342021001121b0a0f72" . "657065617465645f75696e743332185c2003280d42021001121b0a0f7265" . "7065617465645f75696e743634185d2003280442021001121b0a0f726570" . "65617465645f73696e743332185e2003281142021001121b0a0f72657065" . "617465645f73696e743634185f2003281242021001121c0a107265706561" . "7465645f6669786564333218602003280742021001121c0a107265706561" . "7465645f6669786564363418612003280642021001121d0a117265706561" . "7465645f736669786564333218622003280f42021001121d0a1172657065" . "617465645f736669786564363418632003281042021001121a0a0e726570" . "65617465645f666c6f617418642003280242021001121b0a0f7265706561" . "7465645f646f75626c651865200328014202100112190a0d726570656174" . "65645f626f6f6c1866200328084202100112280a0d72657065617465645f" . "656e756d18672003280e320d2e666f6f2e54657374456e756d4202100122" . "b9030a1354657374556e7061636b65644d657373616765121a0a0e726570" . "65617465645f696e743332185a2003280542021000121a0a0e7265706561" . "7465645f696e743634185b2003280342021000121b0a0f72657065617465" . "645f75696e743332185c2003280d42021000121b0a0f7265706561746564" . "5f75696e743634185d2003280442021000121b0a0f72657065617465645f" . "73696e743332185e2003281142021000121b0a0f72657065617465645f73" . "696e743634185f2003281242021000121c0a1072657065617465645f6669" . "786564333218602003280742021000121c0a1072657065617465645f6669" . "786564363418612003280642021000121d0a1172657065617465645f7366" . "69786564333218622003280f42021000121d0a1172657065617465645f73" . "6669786564363418632003281042021000121a0a0e72657065617465645f" . "666c6f617418642003280242021000121b0a0f72657065617465645f646f" . "75626c651865200328014202100012190a0d72657065617465645f626f6f" . "6c1866200328084202100012280a0d72657065617465645f656e756d1867" . "2003280e320d2e666f6f2e54657374456e756d420210002a1d0a08546573" . "74456e756d12080a045a45524f100012070a034f4e451001620670726f74" . "6f33"));