Exemplo n.º 1
0
 /**
  * Assign the element at the given index.
  *
  * This will also be called for: $arr []= $ele and $arr[0] = ele
  *
  * @param long $offset The index of the element to be assigned.
  * @param object $value The element to be assigned.
  * @return void
  * @throws ErrorException Invalid type for index.
  * @throws ErrorException Non-existing index.
  * @throws ErrorException Incorrect type of the element.
  */
 public function offsetSet($offset, $value)
 {
     switch ($this->type) {
         case GPBType::INT32:
             GPBUtil::checkInt32($value);
             break;
         case GPBType::UINT32:
             GPBUtil::checkUint32($value);
             break;
         case GPBType::INT64:
             GPBUtil::checkInt64($value);
             break;
         case GPBType::UINT64:
             GPBUtil::checkUint64($value);
             break;
         case GPBType::FLOAT:
             GPBUtil::checkFloat($value);
             break;
         case GPBType::DOUBLE:
             GPBUtil::checkDouble($value);
             break;
         case GPBType::BOOL:
             GPBUtil::checkBool($value);
             break;
         case GPBType::STRING:
             GPBUtil::checkString($value, true);
             break;
         case GPBType::MESSAGE:
             GPBUtil::checkMessage($value, $this->klass);
             break;
         default:
             break;
     }
     if (is_null($offset)) {
         $this->container[] = $value;
     } else {
         $count = count($this->container);
         if (!is_numeric($offset) || $offset < 0 || $offset >= $count) {
             trigger_error("Cannot modify element at the given index", E_USER_ERROR);
             return;
         }
         $this->container[$offset] = $value;
     }
 }
Exemplo n.º 2
0
 public function setOneofInt64($var)
 {
     GPBUtil::checkInt64($var);
     $this->writeOneof(52, $var);
 }
Exemplo n.º 3
0
 public function setNegativeIntValue($var)
 {
     GPBUtil::checkInt64($var);
     $this->negative_int_value = $var;
     $this->has_negative_int_value = true;
 }