private function getKey(&$obj) { if (is_string($obj)) { $key = 's_' . $obj; } elseif ($obj instanceof HproseBytes) { $key = 'b_' . $obj->value; } elseif (is_array($obj)) { if (($i = array_ref_search($obj, $this->arrayref)) === false) { $i = count($this->arrayref); $this->arrayref[$i] =& $obj; } $key = 'a_' . $i; } elseif ($obj instanceof HproseMap) { if (($i = array_ref_search($obj->value, $this->arrayref)) === false) { $i = count($this->arrayref); $this->arrayref[$i] =& $obj->value; } $key = 'm_' . $i; } else { $key = 'o_' . spl_object_hash($obj); } return $key; }
function hprose_hash(&$v, $ro) { if (is_string($v)) { return 's_' . $v; } if ($v instanceof HproseBytes) { return 'b_' . $v->value; } if (is_array($v)) { if (($i = array_ref_search($v, $ro->ar)) === false) { $i = count($ro->ar); $ro->ar[$i] =& $v; } return 'a_' . $i; } if ($v instanceof HproseMap) { if (($i = array_ref_search($v->value, $ro->ar)) === false) { $i = count($ro->ar); $ro->ar[$i] =& $v->value; } return 'm_' . $i; } return 'o_' . spl_object_hash($v); }
private function writeRef(&$obj, $checkRef, $writeBegin, $writeEnd) { if (is_string($obj)) { $key = 's_' . $obj; } elseif (is_array($obj)) { if (($i = array_ref_search($obj, $this->arrayref)) === false) { $i = count($this->arrayref); $this->arrayref[$i] =& $obj; } $key = 'a_' . $i; } else { $key = 'o_' . spl_object_hash($obj); } if ($checkRef && array_key_exists($key, $this->ref)) { $this->stream->write(HproseTags::TagRef . $this->ref[$key] . HproseTags::TagSemicolon); } else { $result = $writeBegin ? call_user_func_array($writeBegin, array(&$obj)) : false; $index = count($this->ref); $this->ref[$key] = $index; call_user_func_array($writeEnd, array(&$obj, $result)); } }