Converts array to object,

@param array $array The array to convert.
@param \stdClass|mixed|null $object The result object.
@param string $type The type of data that the function should return. Default: \stdClass

@return void
326362
public static function arrayToObject($array, &$object = null, $type = null) {
        $object = isset($object) ? $object : (isset($type) ? new $type() : new \stdClass());

        ksort($array);

        foreach ($array as $key => $value)
        {
            if (strpos($key, '_') === false) {
                $activeObject = $object;
                
                if (is_array($object) && $type !== null) {
                    $activeObject = new $type();
                    $object[] = $activeObject;
                }

                // is array
                if (substr($key, -1) == ']') {
                    $key = substr($key, 0, strrpos($key, '['));

                    if (!isset($activeObject->$key) || !is_array($activeObject->$key)) {
                        $activeObject->$key = array();
                    }

                    if (is_array($value)) {
                        foreach ($value as $v) {
                            $activeObject->{$key}[] = $v;
                        }
                    }
                    else {
                        $activeObject->{$key}[] = $value;
                    }
                }
                else {
                    $activeObject->$key = $value;
                }
            } else {
                $name = explode('_', $key);
                $activeObject = $object;

                while (count($name) > 1) {
                    $current = array_shift($name);
                    $isArray = false;

                    // is array
                    if (substr($current, -1) == ']') {
                        $index = substr($current, strrpos($current, '[') + 1, -1);
                        $current = substr($current, 0, strrpos($current, '['));
                        $isArray = true;
                    }

                    if (isset($activeObject->$current)) {
                        if ($isArray) {
                            if (!isset($activeObject->$current[$index])) {
                                $activeObject->$current[$index] = (isset($type) ? new $type() : new \stdClass());
                            }

                            $activeObject = $activeObject->$current[$index];
                        }
                        else {
                            $activeObject = $activeObject->$current;
                        }

                        continue;
                    }

                    $reflection = new \ReflectionClass($activeObject);

                    if (isset($reflection) &&  $reflection->hasProperty($current)) {
                        $property = $reflection->getProperty($current);

                        if (($propertyComment = $property->getDocComment()) !== null && $propertyComment !== '' && preg_match('/@var\s+(?<name>[^\n]+)/', $propertyComment, $m) === 1) {
                            $propertyType = trim($m[1]);

                            if (substr($propertyType, -1) == ']') {
                                $propertyType = substr($propertyType, 0, strrpos($propertyType, '['));
                            }

                            if (!class_exists($propertyType)) {
                                if (is_object($object)) {
                                    $objectReflection = new \ReflectionClass($object);
                                    $propertyTypeNamesapce = $objectReflection->getNamespaceName();
                                }
                                elseif ($type !== null && $type != '\stdClass') {
                                    $propertyTypeNamesapce = substr($type, 0, strrpos($type, '\\'));
                                }

                                if (class_exists($propertyTypeNamesapce . '\\' . $propertyType)) {
                                    $propertyType = $propertyTypeNamesapce . '\\' . $propertyType;
                                }
                                else {
                                    $propertyType = '\stdClass';
                                }
                            }
                        }
                        else {
                            $propertyType = '\stdClass';
                        }
                    }
                    else {
                        $propertyType = '\stdClass';
                    }

                    if ($isArray) {
                        $newObject = array();
                        $newObject[$index] = new $propertyType();
                        $type = $propertyType;
                    }
                    else {
                        $newObject = new $propertyType();
                        $type = null;
                    }

                    if (isset($property)) {
                        $property->setValue($activeObject, $newObject);
                    }
                    else {
                        $activeObject->$current = $newObject;
                    }

                    $activeObject = ($isArray ? $newObject[$index] : $newObject);
                }

                self::arrayToObject(array($name[0] => $value), $activeObject, $type);
            }
        }
    }
1241702
private function cloneArray(array &$array): void
    {
        foreach ($array as $key => $value) {
            if (is_object($value)) {
                $array[$key] = clone $value;
            }
            if (is_array($value)) {
                $this->cloneArray($array[$key]);
            }
        }
    }
1277971
public static function toArray( $object )
    {
        if ( is_object( $object ) )
        {
            return get_object_vars( $object );
        }

        if ( is_array( $object ) )
        {
            return array_map(
                array(
                    __CLASS__,
                    'toArray'
                ),
                $object
            );
        }

        // Return array
        return $object;
    }
550437
public static function to_object($array, $recursive = false) {
        if (!is_object($array) && !is_array($array)) return $array;

        if (!$recursive) return (object)$array;

        if (is_array($array)) return (object)array_map([
            __CLASS__,
            'to_object'
        ], $array);
        else return $array;
    }
1021341
public static function fromObject($object)
    {
        if (\is_object($object)) {
            $object = (array)$object;
        }
        if (\is_array($object)) {
            $array = [];
            foreach ($object as $key => $value) {
                $array[$key] = self::fromObject($value);
            }
        } else {
            $array = $object;
        }
        return $array;
    }
1262949
public static function decodeArrayFromBase64(array $array, string $type = null): array
    {
        foreach ($array as &$v) {
            $v = self::run(self::DECODER, \base64_decode($v), $type);
        }

        return $array;
    }
218242
public function fromArray(array $object = array())
    {
        if (count($object) > 0) {
            $reflector = new \ReflectionClass($this);
            $properties = InjectorHelper::extractProperties($reflector, \ReflectionProperty::IS_PUBLIC, InjectorHelper::VAR_PATTERN);
            unset($reflector);
            foreach ($object as $key => $value) {
                if (property_exists($this, $key) && null !== $value) {
                    $this->parseDtoField($properties, $key, $value);
                }
            }
        }
    }
661911
protected static function objectRecursive(Array $array, stdClass &$std) : stdClass
    {
        foreach( $array as $key => $value )
        {
            if( is_array($value) )
            {
                $std->$key = new stdClass;

                self::objectRecursive($value, $std->$key);
            }
            else
            {
                $std->$key = $value;
            }
        }

        return $std;
    }
864829
private function convert(Array $object): Array {
    $parse = Array();
    foreach ($object as $key => $value) {
      if ($value instanceof stdClass) {
        $parse[$key] = $this->convert((Array) $value);
      } else {
        $parse[$key] = $value;
      }
    }
    return $parse;
  }
1069953
public function copyToArray(array &$array)
    {
        parent::copyToArray($array);

        $array['serviceApiKey']       = $this->serviceApiKey;
        $array['clientId']            = $this->clientId;
        $array['subject']             = $this->subject;
        $array['latestGrantedScopes'] = $this->latestGrantedScopes;
        $array['mergedGrantedScopes'] = $this->mergedGrantedScopes;
        $array['modifiedAt']          = LanguageUtility::orZero($this->modifiedAt);
    }
1362876
public static function getObjectWithKeyAndValue(array $array, $key, $value)
    {
        foreach ($array as $object) {
            if (is_array($object) && array_key_exists($key, $object) && $object[$key] === $value) {
                return $object;
            }
        }

        return null;
    }
326497
protected function arrayToObject(array $array)
    {
        $obj = (object) [];

        foreach ($array as $k => $v) {

            if (strlen($k)) {
                if (is_array($v)) {
                    $obj->{$k} = $this->arrayToObject($v);
                } else {
                    $obj->{$k} = $v;
                }
            }
        }

        return $obj;
    }
854657
public static function buildObject($array) {
        $obj = new \stdClass();

        foreach ($array as $key => $value) {
            if (is_array($value) || is_object($value)) {
                $obj->{$key} = static::buildObject($value);
            } else {
                $obj->{$key} = static::autobox($value);
            }
        }

        return $obj;
    }
1118887
public function loadFromArray($object)
    {
        unset($this->custom1, $this->custom2, $this->custom3, $this->custom4);

        return parent::loadFromArray($object);
    }
1047680
public function toObject(array $data, $object)
    {
        $className = $this->getFullClassName($object);
        $metadata = $this->metadataFactory->getMetadataForClass($className);
        $unserializedProperties = 0;
        foreach ($metadata->getProperties() as $property) {
            if (!$property->isExpose() || $this->propertySkipper->shouldSkip($property)) {
                if ($this->isMediumStrictUnserializeMode() && array_key_exists($property->getSerializedName(), $data)) {
                    throw new InvalidArgumentException(sprintf('%s extra field', $property->getSerializedName()));
                }
                continue;
            }

            if (!array_key_exists($property->getSerializedName(), $data)) {
                if ($this->isStrictUnserializeMode()) {
                    throw new InvalidArgumentException(sprintf('%s field is lost', $property->getSerializedName()));
                }
                continue;
            }
            $value = $this->handleValue($data[$property->getSerializedName()], $property, self::DIRECTION_UNSERIALIZE, $object);

            if ($value === $object) {
                throw new RecursionException(sprintf('Invalid self reference detected. %s::%s', $className, $property->getName()));
            }

            $this->involveValue($object, $property, $value);
            $unserializedProperties ++;
        }

        if ($this->isMediumStrictUnserializeMode() && $unserializedProperties !== count($data)) {
            throw new InvalidArgumentException('Wrong number of fields in the deserialized data');
        }

        return $object;
    }
1189395
protected <Type> void addIfNotNull(final Array<Type> array, final Type object) {
        if (object != null) {
            array.add(object);
        }
    }
246905
public static function serialize($object)
	{
		if (is_array($object)) {
			$result = [];
			foreach ($object as $record) {
				$result[] = $record->toArray();
				$record = null;
			}
			$object = null;
			return $result;
		} else {
			return $object != null ? $object->toArray() : null;
		}
	}