Merge objects
@param \stdClass $obj
@return \stdClass|array
@throws \Exception
974732
public function assign($obj, ...$args)
    {
        if(is_object($obj)){
            foreach($args as &$source){
                if (!isset($source)) continue;

                if ( !is_object($source) ) {
                    throw new \Exception($source . 'must be object');
                }
                foreach($source as $key=>&$val){
                    $obj->{$key} = $source->{$key};
                }
            }
        }else{
            throw new \Exception("Utlis::assign() parameter 1 by not object");
        }

        return $obj;
    }
441111
def merge_objects(self, mujoco_objects):
        """"""
        self.mujoco_objects = mujoco_objects
        self.objects = {}  # xml manifestation
        self.max_horizontal_radius = 0
        for obj_name, obj_mjcf in mujoco_objects.items():
            self.merge_asset(obj_mjcf)
            # Load object
            obj = obj_mjcf.get_collision(name=obj_name, site=True)
            obj.append(new_joint(name=obj_name, type="free", damping="0.0005"))
            self.objects[obj_name] = obj
            self.worldbody.append(obj)

            self.max_horizontal_radius = max(
                self.max_horizontal_radius, obj_mjcf.get_horizontal_radius()
            )
130838
private function hydrateClassObject($obj, $data)
    {
        // loop through the class object and hydrate it
        foreach ($data as $property => $value) {
            $this->hydrate($obj, $property, $value);
        }

        return $obj;
    }
613503
public function delete($obj)
    {
        $this->startProfiling();

        $result = parent::delete($obj);

        $this->endProfiling('delete', $result);
        $this->clearParams();

        return $result;
    }
929864
private function toArray($obj) {
        $arr = array();

        if (is_array($obj)) {
            foreach ($obj as $value) {
                $arr[] = $this->toArray($value);
            }
        } else if (is_object($obj)) {
            $arObj = (array) $obj;
            foreach ($arObj as $key => $value) {
                $attribute = str_replace(get_class($obj), "", $key);
                if (is_object($value) || is_array($value)) {
                    $value = $this->toArray($value);
                } else {
                    $arr[$attribute] = $this->utf8_encode_all($value);
                }
            }
        } else {
            $arr = $this->utf8_encode_all($obj);
        }
        return $arr;
    }
951679
public function arrangeObject($object, $order = array())
    {

        if (!is_object($object))
            throw new Exception("Please provide a valid Object for the arrangeObject method");
        if (!is_array($order) || empty($order))
            throw new Exception("Please provide a valid orderArray for the arrangeObject method");

        $obj = new stdClass();

        foreach ($order as $key) {
            $obj->$key = $object->$key;
        }
        return $obj;
    }
630069
public function push($obj)
    {
        if (!$obj) {
            return;
        }

        $cls           = get_called_class();
        $escape        = Driver::$escape_char;
        $value         = array_key_exists(self::getPK(), $this->_data) ? $this->_data[self::getPK()] : null;
        $other_cls     = get_class($obj);
        $other_pk      = $other_cls::getPK();
        $other_value   = $obj->get($other_pk);
        $table         = Model::getTableName($other_cls);
        $foreign       = self::hasManyForeignKey(Inflections::pluralize(strtolower($other_cls)));

        // if the current object exists ...
        if (!is_null($value)) {
            $obj->set(strtolower($foreign), $value);

            // if the pushed object is still not saved
            if (is_null($other_value)) {
                if (!$obj->save()) {
                    return false;
                }
                $other_value = $obj->get($other_pk);
            }

            $foreign    = self::$_mapping[$other_cls][$foreign];
            $other_pk   = self::$_mapping[$other_cls][$other_pk];
            $sql        = "update $escape$table$escape set $escape$foreign$escape=$value where $escape$other_pk$escape=$other_value";
            $stmt       = self::query($sql);
            $rst        = $stmt->rowCount()==1;
            self::closeCursor($stmt);
            return $rst;
        }

        // if current object does not exists ...
        if (is_null($value)) {
            $this->_pushLater($obj);
        }
    }
922393
public function objectToDom($obj)
    {
        $doc = new DomDocument('1.0', 'utf-8');

        foreach ($obj as $k => &$v) {
            $node = $this->objectToDomElement($v, $doc->createElement($k), $doc);
            break;
        }

        $doc->appendChild($node);

        return $doc;
    }
1009994
public function _mergeWithPrevious($previous)
    {
        if ($previous == null)
        {
            return $this;
        }
        if ($previous instanceof AVRelationOperation)
        {
            if ($previous->targetClassName != null && $previous->targetClassName != $this->targetClassName
            )
            {
                throw new \Exception('Related object object must be of class ' . $this->targetClassName . ', but ' . $previous->targetClassName . ' was passed in.');
            }
            $newRelationToAdd = self::convertToOneDimensionalArray($this->relationsToAdd);
            $newRelationToRemove = self::convertToOneDimensionalArray($this->relationsToRemove);

            $previous->addObjects($newRelationToAdd, $previous->relationsToAdd);
            $previous->removeObjects($newRelationToAdd, $previous->relationsToRemove);

            $previous->removeObjects($newRelationToRemove, $previous->relationsToAdd);
            $previous->addObjects($newRelationToRemove, $previous->relationsToRemove);

            $newRelationToAdd = self::convertToOneDimensionalArray($previous->relationsToAdd);
            $newRelationToRemove = self::convertToOneDimensionalArray($previous->relationsToRemove);

            return new AVRelationOperation($newRelationToAdd, $newRelationToRemove);
        }
        throw new \Exception('Operation is invalid after previous operation.');
    }
81085
public function whereTuple($obj)
    {
        $where = $obj->buildWhere();
        if ($where) {
            $where = substr($where, 6);
        }
        $this->_sql['wheretuple'][] = [$where, 'and'];
        return $this;
    }
84246
public function exportToObj($obj) {
		foreach($this->properties as $k=>$v) {
			if (!is_array($v) && !is_object($v))
			$obj->$k = $v;
		}
	}
729565
private function convertFromDB($obj)
    {
        foreach ($this->fields as $field) {
            switch ($field->type()) {
                case self::FIELD_TYPE_BOOL :
                    $obj->{$field->identifier()} = (bool) $obj->{$field->identifier()};
                    break;
                case self::FIELD_TYPE_INT :
                    $obj->{$field->identifier()} = (int) $obj->{$field->identifier()};
                    break;
                case self::FIELD_TYPE_FLOAT :
                    $obj->{$field->identifier()} = (float) $obj->{$field->identifier()};
                    break;
                case self::FIELD_TYPE_STR :
                    break;
                case self::FIELD_TYPE_DATETIME :
                    if ($obj->{$field->identifier()} === '0') {
                        $obj->{$field->identifier()} = false;
                    } else {
                        $d = new \DateTime();
                        if (!is_object($obj->{$field->identifier()})) {
                            $d->setTimestamp($obj->{$field->identifier()});
                            $obj->{$field->identifier()} = $d;
                        }

                        $obj->{$field->identifier()} = $d;
                    }
                    break;
                case self::FIELD_TYPE_STR_ARRAY :
                    $delimiter = '(^!)';
                    if (empty($obj->{$field->identifier()}))
                        $obj->{$field->identifier()} = [];
                    else
                        $obj->{$field->identifier()} = array_map(function($v) use ($delimiter) {
                            return stripslashes($v);
                        }, explode($delimiter, $obj->{$field->identifier()}));
                    break;
                case self::FIELD_TYPE_INT_ARRAY :
                    $arr = empty($obj->{$field->identifier()})
                        ? [] : explode(',', $obj->{$field->identifier()});
                    $obj->{$field->identifier()} = array_map(function($v) { return (int) str_replace('\'', '', $v); }, $arr);
                    break;
                case self::FIELD_TYPE_OBJ :
                    $obj->{$field->identifier()} = empty($obj->{$field->identifier()})
                        ? new \StdClass() : json_decode($obj->{$field->identifier()});
                    break;
                default :
                    throw new TypeNotExistException();
            }
        }

        return $obj;
    }
502216
protected function _convertToArray($obj) {
        $arr    = array();
        $arrObj = is_object($obj) ? get_object_vars($obj) : $obj;

        foreach ($arrObj as $key => $val) {
            if (is_object($val)) {
                switch (get_class($val)) {
                case 'Garp_Spawn_Relation_Set':
                    $val = $val->getRelations();
                    break;
                case 'Garp_Spawn_Behaviors':
                    $val = $val->getBehaviors();
                    break;
                case 'Garp_Spawn_Fields':
                    $val = $val->getFields();
                }

                $val = $this->_convertToArray($val);
            } elseif (is_array($val)) {
                $val = $this->_convertToArray($val);
            }
            $arr[$key] = $val;
        }

        return $arr;
    }
909140
public function append($obj, $check = true)
    {
        if ( $check && $this->findIndexById( $obj->id ) >= 0) return $this;
        $this->elements[] = $obj;
        return $this;
    }
1324988
public function join(&$object)
    {
        $result = true;
        if (method_exists($object, 'getDataForJSON')) {
            $this->chained[] = $object;
        } else {
            throw new \Ease\Exception('$object->getDataForJSON() does not exist');
        }

        return $result;
    }
1221887
public function merge($objs)
    {
        $objs = $this->asArray($objs);

        foreach ($objs as $obj) {
            if (!$this->isAcceptable($obj)) {
                throw new InvalidArgumentException(
                    sprintf(
                        'Must be an array of models, contains %s',
                        (is_object($obj) ? get_class($obj) : gettype($obj))
                    )
                );
            }

            $key = $this->modelKey($obj);
            $this->objects[$key] = $obj;
        }

        return $this;
    }
390123
public function setSection($obj)
    {
        if ($obj instanceof SectionInterface) {
            $this->section = $obj;
        } else {
            $this->createSection();

            $this->section->load($obj);
        }

        return $this;
    }