private static function writeLittleEndian64ToArray($value, &$buffer) { $high = 0; $low = 0; if (PHP_INT_SIZE == 4) { GPBUtil::divideInt64ToInt32($value, $high, $low); } else { $low = $value & 0xffffffff; $high = $value >> 32 & 0xffffffff; } $buffer[0] = chr($low & 0xff); $buffer[1] = chr($low >> 8 & 0xff); $buffer[2] = chr($low >> 16 & 0xff); $buffer[3] = chr($low >> 24 & 0xff); $buffer[4] = chr($high & 0xff); $buffer[5] = chr($high >> 8 & 0xff); $buffer[6] = chr($high >> 16 & 0xff); $buffer[7] = chr($high >> 24 & 0xff); return 8; }
/** * Assign the element at the given key. * * This will also be called for: $arr[$key] = $value * * @param object $key The key of the element to be fetched. * @param object $value The element to be assigned. * @return void * @throws ErrorException Invalid type for key. * @throws ErrorException Invalid type for value. * @throws ErrorException Non-existing key. */ public function offsetSet($key, $value) { checkKey($this->key_type, $key); switch ($this->value_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; } $this->container[$key] = $value; }