Coerce something to list

@param array  $item
@param string $delim

@return array
435325
protected function coerceList($item, $delim = ',')
    {
        if (isset($item) && $item[0] === Type::T_LIST) {
            return $item;
        }

        if (isset($item) && $item[0] === Type::T_MAP) {
            $keys = $item[1];
            $values = $item[2];
            $list = [];

            for ($i = 0, $s = count($keys); $i < $s; $i++) {
                $key = $keys[$i];
                $value = $values[$i];

                $list[] = [
                    Type::T_LIST,
                    '',
                    [[Type::T_KEYWORD, $this->compileStringContent($this->coerceString($key))], $value]
                ];
            }

            return [Type::T_LIST, ',', $list];
        }

        return [Type::T_LIST, $delim, ! isset($item) ? []: [$item]];
    }
737740
public function listToMap(array $list)
    {
        $map = array();
        for ($i = 0, $n = count($list); $i < $n; $i += 2) {
            $map[$list[$i]] = $list[$i + 1];
        }
        return (object)$map;
    }
616029
private static function splitToken($item)
    {
        if (is_array($item)) {
            $tokenName = $item[0];
            $tokenData = $item[1];
        } else {
            $tokenName = null;
            $tokenData = $item;
        }

        return [$tokenName, $tokenData];
    }
603379
protected function prepNewItem($item, $_deps)
    {
        if ($item instanceof Dependable) {
            $_deps = $item->getDependencies();
            $item  = $item->getHandle();
        } elseif ($_deps instanceof Dependable) {
            $_deps = $_deps->getDependencies();
        }
        if (empty($_deps)) {
            $_deps = [];
        } elseif (is_string($_deps)) {
            $_deps = (array)preg_split('/,\s?/', $_deps);
        }

        return [$item, $_deps];
    }
184890
public static List<String> getList(PropertyKey key, String delimiter) {
    return sConf.getList(key, delimiter);
  }
759019
private function getContainerParameters($item)
    {
        $matches = array();
        if (preg_match('/^%([^%]+)%$/', $item, $matches)) {
            if ($this->hasParameter($matches[1])) {
                return $this->getParameter($matches[1]);
            }
        }

        if (preg_match_all('/%([^%]+)%/', $item, $matches, PREG_PATTERN_ORDER)) {
            foreach ($matches[1] as $expr) {
                if ($this->hasParameter($expr)) {
                    $item = str_replace('%'.$expr.'%', $this->getParameter($expr), $item);
                }
            }
        }

        return $item;
    }
210408
public function in($item, array $list, $cond = null, $not = false)
    {
        $inClause = '';

        if (null == $this->oosql_where && null == $this->oosql_in && null == $this->oosql_between) {
            $inClause .= ' WHERE ';
        } else {
            $cnd = ' AND ';

            if (null != $cond) {

                if (strtolower($cond) == 'or') {
                    $cnd = ' OR ';
                }

            }
            $inClause .= $cnd;
        }
        if ($not) {
            $item = $item . ' NOT ';
        }
        $inClause .= $item . ' IN ';

        $obj = $this;

        $list = array_map(function ($data) use ($obj) {
            return (!$obj->validInt($data)) ? $obj->quote($data) : $data;
        }, $list);

        $inClause .= '(' . implode(',', $list) . ')';

        $this->oosql_in = $inClause;

        return $this;
    }
427057
protected function filter( string $item ): bool {

		foreach ( self::$skip as $match ) {
			if ( false !== strpos( $item, $match ) ) {
				return false;
			}
		}

		return true;
	}
172567
protected function evaluateSelect(array $item, $scalar)
    {
        $resultItem = [];
        foreach ($item as $key => $value) {
            if (true === isset($this->select['*']) || true === isset($this->select[$key])) {
                if (true === isset($this->select[$key])) {
                    $value = $this->selectEvaluation->evaluate($value, $this->select[$key]);
                }
                if (true === $scalar) {
                    $resultItem = $value;
                } else {
                    $resultItem[$key] = $value;
                }
            }
        }

        return $resultItem;
    }
587031
private function getRelationships(Item $item)
    {
        if ($include_params = $this->resource->getIncludeParams()) {
            $item->setIncludeParams($include_params);

            return $item->getIncluded();
        }

        return [];
    }
1074228
public function getItem($item)
	{
		return isset($this->items[$item]) ? $this->items[$item] : false;
	}
998388
public function add($item)
    {
        // Disallow items outside of original boundaries
        if (!in_array($item, $this->originalList)) {
            return;
        }
        if (!in_array($item, $this->currentList)) {
            $this->currentList[] = $item;
        }
    }
1042240
public function parse(array $item): array
    {
        $item['groupId'] = $this->getGroupByName($item['group'])->id;
        unset($item['group']);
        $site = new Site($item);

        return [$site, null];
    }
275481
public function parse(array $item): array
    {
        if (\count($item['fieldLayout']) > 1) {
            $errors = [
                'fieldLayout' => [
                    Architect::t('Field layout can only have 1 tab.')

                ]
            ];
            return [null, $errors];
        }

        $tagGroup = new TagGroup([
            'name' => $item['name'],
            'handle' => $item['handle'],
        ]);

        $fieldLayout = new FieldLayout();
        $fieldLayout->type = Tag::class;

        return [$tagGroup, null];
    }
1069133
public function addItem($item)
    {
        if (!isset($this->_items)) {
            $this->_items = [];
        }
        if (!is_array($item)) {
            $item = [];
        }
        if (!isset($item['class'])) {
            $item['class'] = $this->itemClass;
        }
        $item = Yii::createObject($item);
        $this->_items[$item->id] = $item;

        return $item;
    }
1265570
public static function asArray($var, $delimeter = ',')
	{
		if (static::is_array($var)) {
			return $var;
		}
		try {
			if (NULL === $var) {
				$result = [];
			} else {
				$var = trim((string) $var);
				$result = strlen($var) ? preg_split('#' . $delimeter . '#i', $var, -1, PREG_SPLIT_NO_EMPTY) : [];
			}
		} catch (Exception $e) {
			$result = [];
		}

		return $result;
	}
19229
private function parseOption(array $item) : Option
    {
        $name = $item['option'];

        $characteristic = $item['characteristic'] ?? null;

        if (isset($characteristic))
        {
            $characteristic = self::optionCharacteristic($characteristic);
        }

        $type = $item['type'] ?? null;

        $default = $item['default'] ?? null;

        $description = $item['description'] ?? null;

        $fixedName = $item['name'] ?? null;

        $option = new Option($name, $characteristic, $type, $default);

        if (isset($description))
        {
            $option->setDescription($description);
        }

        if (isset($fixedName))
        {
            if ($fixedName[0] === '-')
            {
                throw new OptionLoaderException(
                    "An option's fixed name may not start with a `-`.",
                    $item
                );
            }

            $option->setFixedName($fixedName);
        }

        if (isset($item['aliases']))
        {
            foreach ($item['aliases'] as $alias)
            {
                $aliasCharacteristic = $alias['characteristic'] ?? null;

                if (isset($aliasCharacteristic))
                {
                    $aliasCharacteristic = self::optionCharacteristic(
                        $aliasCharacteristic
                    );
                }

                $aliasName = $alias['option'] ?? null;

                if ( ! isset($aliasName))
                {
                    throw new OptionLoaderException(
                        "An alias must contain its own option name.",
                        $alias
                    );
                }

                new AliasOption($aliasName, $aliasCharacteristic, $option);
            }
        }

        if (isset($fixedName))
        {
            $this->optionCatalogue[$fixedName] = $option;
        }

        $this->optionCatalogue[$option->getPrintableName()] = $option;

        return $option;
    }