Convert LiveDocx service return value from list methods to consistent
PHP array.

@param stdClass $list

@return array

@internal
970278
public function backendListArrayToMultiAssocArray(stdClass $list)
    {
        $ret = array();

        if ( isset($list->ArrayOfString) ) {
            foreach ( $list->ArrayOfString as $a ) {
                if ( is_array($a) ) {      // 1 template only
                    $o         = new StdClass();
                    $o->string = $a;
                } else {                 // 2 or more templates
                    $o = $a;
                }
                unset($a);

                if ( isset($o->string) ) {
                    $date1 = DateTime::createFromFormat(DateTime::RFC1123 , $o->string[ 3 ]);
                    $date2 = DateTime::createFromFormat(DateTime::RFC1123 , $o->string[ 1 ]);
                    $ret[] = array(
                        'filename'   => $o->string[ 0 ] ,
                        'fileSize'   => ( integer ) $o->string[ 2 ] ,
                        'createTime' => ( integer ) $date1->getTimestamp() ,
                        'modifyTime' => ( integer ) $date2->getTimestamp() ,
                    );
                    unset($date1 , $date2);
                }
            }
        }

        return $ret;
    }
1058378
public static function nextRanges(ObjectList $list): array
    {
        $ranges = [];

        // The end index of the next list. We do this here in case there are no further ranges to return.
        $endIndex = $list->getStartIndex() + $list->getItemsPerPage() - 1;

        // The last index of the final list.
        $finalEndIndex = $list->getTotalResults();

        while ($endIndex < $finalEndIndex) {
            // The start index of the next list.
            $startIndex = ($startIndex ?? $list->getStartIndex()) + $list->getEntryCount();

            // We need to be sure we never return an end range greater than the total count of objects.
            $endIndex = min($startIndex + $list->getItemsPerPage() - 1, $finalEndIndex);

            $range = new self();
            $range->setStartIndex($startIndex)
                ->setEndIndex($endIndex);
            $ranges[] = $range;
        }

        return $ranges;
    }
110904
protected function formatJSON(SS_List $list) {
		$ret = array ();
		foreach($list as $item) {
			$ret[] = array(
				'id' => $item->{$this->idField},
				'label' => $item->{$this->labelField}
			);
		}

		return Convert::array2json($ret);
	}
1142630
function jsonSerialize(): \stdClass {
    return (object) [
      'testName' => $this->getTestName(),
      'records' => array_map(function(Record $item) {
        return $item->jsonSerialize();
      }, $this->getRecords()->getArrayCopy())
    ];
  }
410777
protected function cast($input, SplObjectStorage $list)
    {
        $value = $input instanceof JsonSerializable
            ? $input->jsonSerialize()
            : $input;

        if ($value instanceof DateTimeInterface) {
            $value = $value->format(DateTime::ISO8601);
        }

        if (is_iterable($value)) {
            $value = i\iterable_to_array($value, true);
        }

        if (is_array($value) || $value instanceof stdClass) {
            $value = $this->castRecursive($input, $value, $list);
        }

        return $value;
    }
115312
protected function fill_collections($list=""){
		$names=explode(",",$list);
		for ($i=0; $i < sizeof($names); $i++) { 
			$name = $this->resolve_parameter($names[$i]);
			if (!array_key_exists($name,$this->options)){
				$this->options[$name] = new DistinctOptionsConnector($this->get_connection(),$this->names["db_class"]);
				$c = new DataConfig($this->config);
				$r = new DataRequestConfig($this->request);
				$c->minimize($name);
				
				$this->options[$name]->render_connector($c,$r);
			} 
			
			$this->extra_output.="<coll_options for='{$names[$i]}'>";
			if (!is_string($this->options[$name]))
				$this->extra_output.=$this->options[$name]->render();
			else
				$this->extra_output.=$this->options[$name];
			$this->extra_output.="</coll_options>";
		}
	}
80764
protected function parse(array $list)
    {
        $parsed = array();

        foreach ($list as $item) {
            $item = explode(';', trim($item));

            $entry = array(
                'encoding' => array_shift($item),
                'q' => 1
            );

            foreach ($item as $param) {
                $param = explode('=', $param);

                // ignore malformed params
                if (count($param) != 2) {
                    continue;
                }

                $entry[$param[0]] = $param[1];
            }

            $parsed[] = $entry;
        }

        return $parsed;
    }
665647
public function translateActiveRecordList($list, $propertyName) {
		
		if (!isset($list[0]) or !property_exists($list[0], $propertyName)) {
			return $list;
		}
		
		$translatedVar = 'translated' . ucfirst($propertyName);
		
		foreach ($list as $item) {
			$item->$translatedVar = $this->get($item->$propertyName);
		}
		
		return $list;
		
	}
145051
public function hash(array $list)
    {
        $ids = '';
        foreach ($list as $item) {
            $ids .= ':'.$item['id'];
        }
        return md5($ids);
    }
1081081
public static function getList($data)
    {
        // Return Null if Null
        if ($data === null) {
            return null;
        }

        if (is_a($data, get_class(new \stdClass()))) {
            //This means, root element is object
            return new static(json_encode($data));
        }

        $list = array();

        if (is_array($data)) {
            $data = json_encode($data);
        }

        if (JsonValidator::validate($data)) {
            // It is valid JSON
            $decoded = json_decode($data);
            if ($decoded === null) {
                return $list;
            }
            if (is_array($decoded)) {
                foreach ($decoded as $k => $v) {
                    $list[] = self::getList($v);
                }
            }
            if (is_a($decoded, get_class(new \stdClass()))) {
                //This means, root element is object
                $list[] = new static(json_encode($decoded));
            }
        }

        return $list;
    }
1171724
public function synchronize(SubscriberListInterface $list)
    {
        $listData = $this->listRepository->findById($list->getListId());

        // get Subscribers from the provider
        $subscribers = $list->getProvider()->getSubscribers();

        // unsubscribe difference
        $this->unsubscribeDifference($list->getListId(), $subscribers);
        // subscribe the rest
        return $this->batchSubscribe($list->getListId(), $subscribers);
    }
285133
public static function getPlugins(array $list = [])
    {
        $plugins = [];

        if (!empty($list)) {
            foreach ($list as $plug) {
                if (class_exists($plug['class'])) {
                    $plugins[] = json_decode($plug['class']::getInfo());
                }
            }
        }

        return $plugins;
    }
865960
protected static function prepare_list($list) {
        global $OUTPUT;
        $foldericon = $OUTPUT->image_url(file_folder_icon(24))->out(false);

        // Reset the array keys because non-numeric keys will create an object when converted to JSON.
        $list = array_values($list);

        $len = count($list);
        for ($i = 0; $i < $len; $i++) {
            if (is_object($list[$i])) {
                $file = (array)$list[$i];
                $converttoobject = true;
            } else {
                $file =& $list[$i];
                $converttoobject = false;
            }

            if (isset($file['source'])) {
                $file['sourcekey'] = sha1($file['source'] . self::get_secret_key() . sesskey());
            }

            if (isset($file['size'])) {
                $file['size'] = (int)$file['size'];
                $file['size_f'] = display_size($file['size']);
            }
            if (isset($file['license']) && get_string_manager()->string_exists($file['license'], 'license')) {
                $file['license_f'] = get_string($file['license'], 'license');
            }
            if (isset($file['image_width']) && isset($file['image_height'])) {
                $a = array('width' => $file['image_width'], 'height' => $file['image_height']);
                $file['dimensions'] = get_string('imagesize', 'repository', (object)$a);
            }
            foreach (array('date', 'datemodified', 'datecreated') as $key) {
                if (!isset($file[$key]) && isset($file['date'])) {
                    $file[$key] = $file['date'];
                }
                if (isset($file[$key])) {
                    // must be UNIX timestamp
                    $file[$key] = (int)$file[$key];
                    if (!$file[$key]) {
                        unset($file[$key]);
                    } else {
                        $file[$key.'_f'] = userdate($file[$key], get_string('strftimedatetime', 'langconfig'));
                        $file[$key.'_f_s'] = userdate($file[$key], get_string('strftimedatetimeshort', 'langconfig'));
                    }
                }
            }
            $isfolder = (array_key_exists('children', $file) || (isset($file['type']) && $file['type'] == 'folder'));
            $filename = null;
            if (isset($file['title'])) {
                $filename = $file['title'];
            }
            else if (isset($file['fullname'])) {
                $filename = $file['fullname'];
            }
            if (!isset($file['mimetype']) && !$isfolder && $filename) {
                $file['mimetype'] = get_mimetype_description(array('filename' => $filename));
            }
            if (!isset($file['icon'])) {
                if ($isfolder) {
                    $file['icon'] = $foldericon;
                } else if ($filename) {
                    $file['icon'] = $OUTPUT->image_url(file_extension_icon($filename, 24))->out(false);
                }
            }

            // Recursively loop over children.
            if (isset($file['children'])) {
                $file['children'] = self::prepare_list($file['children']);
            }

            // Convert the array back to an object.
            if ($converttoobject) {
                $list[$i] = (object)$file;
            }
        }
        return $list;
    }
1131069
protected function prepareList(array $list)
    {
        foreach ($list as &$item) {
            if (!empty($item['data']['conditions'])) {
                gplcart_array_sort($item['data']['conditions']);
            }
        }

        return $list;
    }
856090
public function parse(string $list)
    {
        if (!$list) {
            return $list;
        }

        $list = collect(explode(',', $list));

        return $list->map(function ($item) {
            $parts = explode(':', $item);
            $model = app()->make(config('mentions.pools.'.$parts[0].'.model'));
            return $model::findOrFail($parts[1]);
        });
    }
218852
public function getEntryList(array $list, $trusted)
    {
        $flatten = array();
        $this->flattenArray($list, $flatten);
        $entries = array();
        foreach ($flatten as $elm) {
            $entry = $this->getEntry($elm);
            if ($entry) {
                $entries[] = $entry;
            }
        }
        return new EntryList($entries, $trusted);
    }
591649
protected function __apiRestore(array $list)
    {
        HCPagesTranslations::onlyTrashed()->whereIn('record_id', $list)->restore();
        $pages = HCPages::onlyTrashed()->whereIn('id', $list)->get();

        foreach ($pages as $page) {
            $page->restore();
            $page->removeCachedMenu();
        }

        return hcSuccess();
    }