Helper function that builds a single array combining all the items passed as:
'item1','item2'...
'item1, item2...'
array('item1','item2'...)
and mixes of the above.

@param   array   $args
@return  array
430963
private function buildArrayOfArgs($args)
  {
    $result = array();
    
    foreach($args as $arg)
      if ( is_array($arg) )
        $result = array_merge($result, $arg);
      else if ( is_string($arg) )
        if (false !== strpos($arg, ','))
          $result = array_merge($result, array_map('trim', explode(',',$arg)));
        else
          $result[] = $arg;
      else
        $this->debug && trigger_error(sprintf('Argument "%s" of type %s is skipped.', $arg, gettype($arg)), E_USER_WARNING);
        
    return $result;
  }
515806
public static function arguments(array $args) : array
    {
        putenv("CODGER_DRY=1");
        foreach ($args as $key => $value) {
            if ($value === '-w') {
                putenv("CODGER_DRY=0");
                unset($args[$key]);
            }
            if ($value === '-o') {
                putenv("CODGER_OVERWRITE=1");
                putenv("CODGER_DRY=0");
                unset($args[$key]);
            }
            if ($value === '-d') {
                putenv("CODGER_OVERWRITE=0");
                putenv("CODGER_DUMP=1");
                putenv("CODGER_DRY=0");
                unset($args[$key]);
            }
            if ($value === '-s') {
                putenv("CODGER_OVERWRITE=0");
                putenv("CODGER_SKIP=1");
                putenv("CODGER_DRY=0");
                unset($args[$key]);
            }
        }
        return array_values($args);
    }
61617
protected function encodeContent(array $args) {
        $data = [];
        foreach ($args as $key => $item) {
            $data[] = sprintf('"%s":"%s"', $key, $item);
        }
        $arg = '{'.implode(',', $data).'}';
        if (!empty($this->encryptKey)
            && $this->encryptType == self::AES) {
            return (new Aes($this->encryptKey))->encrypt($arg);
        }
        return $arg;
    }
279126
private static function checkArgs(array $args) {
        if ($_FILES) {
            foreach ($_FILES as $key => $f) {
                if (is_array($f['name'])) {
                    foreach ($f['tmp_name'] as $tmp) {
                        $args[ $key ][] = self::getfileSha1('@"' . $tmp . '"');
                    }
                } else {
                    $args[ $key ] = self::getfileSha1('@"' . $f['tmp_name'] . '"');
                }
            }
        }

        return $args;
    }
834759
protected function buildWhereOne(...$args)
    {
        $equal = count($args) === 3;
        $_value = $args[1 + $equal];
        $opr   = $equal ? $args[1] : (is_array($_value) ? 'in' : '=');

        $raw    = false;

        if ($args[1 + $equal] instanceof RawQuery || $args[1 + $equal] instanceof InstructionSelect)
        {
            $_value = '(' . (string)$args[1 + $equal] . ')';
            $raw    = true;
            $this->push($args[1 + $equal]->attributes());
        }

        if ($raw)
        {
            $value = $_value;
        }
        else
        {
            $value = '?';
            if (is_array($_value))
            {
                $value = str_repeat('?, ', count($_value));
                $value = '(' . rtrim($value, ', ') . ')';
                $this->push($_value);
            }
            else
            {
                $this->push([$_value]);
            }
        }

        $list[] = $this->builder->adapter()->quote($args[0]) . ' ' . $opr . ' ' . $value;

        return implode(' ', $list);
    }
1129398
protected function makeMultiple(array $arguments)
    {
        $result = [];
        foreach ($arguments as $argumentName => $argument) {
            $result[$argumentName] = $argument['type'] = new ListType($argument['type']);
        }

        return $result;
    }
921797
public function merge(...$args): self
    {
        $args = array_map([Arr::class, 'toArray'], $args);

        return new static(array_merge($this->storage, ...$args));
    }
1029751
protected function mkdir($args) {
		$target = $args['target'];
		$name   = $args['name'];
		
		if (($volume = $this->volume($target)) == false) {
			return array('error' => $this->error(self::ERROR_MKDIR, $name, self::ERROR_TRGDIR_NOT_FOUND, '#'.$target));
		}

		return ($dir = $volume->mkdir($target, $name)) == false
			? array('error' => $this->error(self::ERROR_MKDIR, $name, $volume->error()))
			: array('added' => array($dir));
	}
751276
private function prepare($args)
    {
        $bindings = array();

        // Two parameters (key, value).
        if (count($args) == 2) {
            $bindings[$args[0]] = $args[1];
        }
        // Array of parameters.
        elseif (is_array($args[0])) {
            $bindings = $args[0];
        }

        return $bindings;
    }
453465
protected function composeCommand($args): string
    {
        $command = $this->getBinary();

        if (\is_array($args)) {
            $args = implode(' ', $args);
        }

        // Only append args if we have some
        $command .= $args !== '' ? ' ' . $args : '';

        return $command;
    }
946079
private function formatArgs(array $args)
    {
        $result = array();
        foreach ($args as $key => $item) {
            if ('object' === $item[0]) {
                $formattedValue = sprintf("<em>object</em>(%s)", $this->abbrClass($item[1]));
            } elseif ('array' === $item[0]) {
                $formattedValue = sprintf("<em>array</em>(%s)", is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
            } elseif ('string'  === $item[0]) {
                $formattedValue = sprintf("'%s'", htmlspecialchars($item[1], ENT_QUOTES | ENT_SUBSTITUTE, $this->charset));
            } elseif ('null' === $item[0]) {
                $formattedValue = '<em>null</em>';
            } elseif ('boolean' === $item[0]) {
                $formattedValue = '<em>' . strtolower(var_export($item[1], true)) . '</em>';
            } elseif ('resource' === $item[0]) {
                $formattedValue = '<em>resource</em>';
            } else {
                $formattedValue = str_replace("\n", '', var_export(htmlspecialchars((string) $item[1], ENT_QUOTES | ENT_SUBSTITUTE, $this->charset), true));
            }

            $result[] = is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue);
        }

        return implode(', ', $result);
    }
650901
private function parseArgs(array $args)
    {
        if (! count($args)) {
            return $this->createHelpArgument();
        }

        $arg1 = array_shift($args);

        if (in_array($arg1, ['-h', '--help', 'help'], true)) {
            return $this->createHelpArgument();
        }

        if (! count($args)) {
            return $this->createErrorArgument('Missing class name');
        }

        $configFile = $arg1;
        switch (file_exists($configFile)) {
            case true:
                $config = require $configFile;

                if (! is_array($config)) {
                    return $this->createErrorArgument(sprintf(
                        'Configuration at path "%s" does not return an array.',
                        $configFile
                    ));
                }

                break;
            case false:
                // fall-through
            default:
                if (! is_writable(dirname($configFile))) {
                    return $this->createErrorArgument(sprintf(
                        'Cannot create configuration at path "%s"; not writable.',
                        $configFile
                    ));
                }

                $config = [];
                break;
        }

        $class = array_shift($args);

        if (! class_exists($class)) {
            return $this->createErrorArgument(sprintf(
                'Class "%s" does not exist or could not be autoloaded.',
                $class
            ));
        }

        return $this->createArguments(self::COMMAND_DUMP, $configFile, $config, $class);
    }
334678
protected function colorArgs($args)
    {
        if ($args[0] != 'list' || count($args[2]) < 2) {
            return array(array('color', 0, 0, 0), 0);
        }
        list($color, $delta) = $args[2];
        $color = $this->assertColor($color);
        $delta = floatval($delta[1]);

        return array($color, $delta);
    }
1193284
protected function normalizeArguments(array $args)
    {
        //normalize arguments
        $normalizedArguments = [];
        foreach ($args as $key => $value) {
            if ($this->executableDefinition->hasArgument($key)) {
                $argument = $this->executableDefinition->getArgument($key);
                if ('input' === $key) {
                    $normalizedValue = $value;
                } else {
                    $normalizedValue = $this->normalizeValue($value, $argument->getType());

                    //normalize argument into respective inputs objects
                    if (\is_array($normalizedValue) && $this->endpoint->hasType($argument->getType())) {
                        if ($argument->isList()) {
                            $tmp = [];
                            foreach ($normalizedValue as $childValue) {
                                $tmp[] = $this->arrayToObject($childValue, $this->endpoint->getType($argument->getType()));
                            }
                            $normalizedValue = $tmp;
                        } else {
                            $normalizedValue = $this->arrayToObject($normalizedValue, $this->endpoint->getType($argument->getType()));
                        }
                    }
                }
                $normalizedArguments[$argument->getName()] = $normalizedValue;
                $normalizedArguments[$argument->getInternalName()] = $normalizedValue;
            }
        }

        return $normalizedArguments;
    }
388797
public function data($args)
    {
        foreach (func_get_args() as $arg) {
            if (is_array($arg)) {
                $this->data = array_merge_recursive($arg, $this->data);
            } else {
                $this->data[] = $arg;
            }
        }

        return $this;
    }
826127
public function build($args)
    {
        $data = [];

        $args = Cuztom::merge($args, [
            'parent'   => $this,
            'metaType' => $this->metaType,
            'object'   => $this->object,
        ]);

        // Build with value
        if (Cuztom::isArray($this->value)) {
            $i = 0;

            foreach ($this->value as $value) {
                $args = Cuztom::merge($args, "index=>$i");

                $data[] = new BundleItem($args, $value);

                $i++;
            }
        }

        // Without value
        else {
            $args = Cuztom::merge($args, 'index=>0');

            $data[] = new BundleItem($args);
        }

        return $data;
    }
426919
protected function recursive_concat(array $args) {
        $count = count($args);
        if ($count == 1) {
            $arg = reset($args);
            return $arg;
        }
        if ($count == 2) {
            $args[] = "' '";
            // No return here intentionally.
        }
        $first = array_shift($args);
        $second = array_shift($args);
        $third = $this->recursive_concat($args);
        return "MOODLELIB.TRICONCAT($first, $second, $third)";
    }