Reformat an argument list.

@param array $arguments The arguments to reformat.

@return mixed
19324
private function formatArguments($arguments)
    {
        $result = [];
        foreach ($arguments as $key => $argument) {
            if (is_object($argument)) {
                $result[$key] = get_class($argument);
                continue;
            }

            if (is_array($argument)) {
                $result[$key] = $this->formatArguments($argument);
                continue;
            }

            $result[$key] = $argument;
        }

        return $result;
    }
539994
public function setArguments(array $arguments)
    {
        switch ($this->argumentsType) {
            case self::ARGUMENTS_TYPE_EMPTY:
                if (!empty($arguments)) {
                    throw new InvalidCommandArgumentException($this, $arguments);
                }
                $arguments = [];
                break;
            case self::ARGUMENTS_TYPE_STRING:
                $this->checkStringArgument($arguments);
                $arguments = [$arguments[0]];
                break;
            case self::ARGUMENTS_TYPE_STRING_INT:
                $this->checkStringArgument($arguments, 2);
                if (!is_int($arguments[1])) {
                    throw new InvalidCommandArgumentException($this, $arguments);
                }
                $arguments = [$arguments[0], (int) $arguments[1]];
                break;
            case self::ARGUMENTS_TYPE_STRINGS:
                $this->checkStringArguments($arguments);
                break;
            // A fallback in case a non-existing argument type is defined.
            // This could be prevented by using an Enum as the argument type
            default:
                throw new InvalidCommandArgumentException($this, $arguments);
        }
        $this->arguments = $arguments;
    }
691433
public function prepare($command, array $arguments = array())
    {
        $commandline = $command;

        foreach ($arguments as $option => $value) {
            if (is_bool($value)) {
                if ($value === true) {
                    $commandline .= ' ' . $option;
                }
            } else {
                $seperator = ' ';
                if (!is_integer($option)) {
                    $commandline .= ' ' . $option;
                    if (substr($option, -1, 1) == '=') {
                        $seperator = '';
                    }
                }
                $commandline .= $seperator . ProcessUtils::escapeArgument($value);
            }
        }

        return $commandline;
    }
378868
public function parse(Array $arguments)
    {
        $this->arguments = array();
        $arguments = new ArgumentIterator($arguments);

        foreach ($arguments as $current) {

            $arguments->next();
            $next = ($arguments->valid() ? $arguments->current() : '');
            $arguments->prev();

            $arg1 = substr($current, 0, 1);
            $arg2 = substr($current, 0, 2);

            if ('--' == $arg2) {

                // ~ Case '--test'
                $arg = array();
                $match = preg_match('`--([0-9a-z_-]+)="?(.+)"?`', $current, $arg);

                if ($match > 0) {
                    $this->arguments[$arg[1]] = $arg[2];
                } else
                    if (! empty($next) && '-' !== substr($next, 0, 1)) {
                        $this->arguments[substr($current, 2)] = $next;
                    } else {
                        $this->arguments[substr($current, 2)] = true;
                    }
            } elseif ('-' == $arg1) {

                // ~ case -t
                $arg = substr($current, 1);
                $len = strlen($arg);

                if (1 == $len && ! empty($next) && '-' != substr($next, 0, 1)) {
                    $this->arguments[$arg] = $next;
                } else {
                    for ($letter = 0; $letter < $len; $letter ++) {
                        $this->arguments[$arg[$letter]] = true;
                    }
                }
            }
        }

        return $this;
    }
508769
public function setArguments($arguments)
    {
        foreach ($arguments as $name => $argument) {
            $this->setArgument($name, $argument);
        }

        return $this;
    }
1300343
public function addArguments(?string $arguments = null)
    {
        $args = [];
        preg_match_all('/(?P<argument>\w+):(?P<value>[\w+\-]+)/', $arguments, $matches);
        if (isset($matches['argument'])) {
            foreach ($matches['argument'] as $key => $argKey) {
                if (isset($matches['value'][$key])) {
                    $args[$argKey] = $matches['value'][$key];
                }
            }
        }
        $this->arguments = $args;
    }
644149
public function prepareCommand(array $arguments = [])
    {
        $result = '';
        foreach ($arguments as $a) {
            $result .= ' ' . escapeshellarg($a);
        }

        return $result;
    }
859983
protected function processArguments($arguments)
    {
        if (false === is_array($arguments)) {
            return $arguments;
        }

        return array_map(function ($argument) {
            return (string) $argument;
        }, $arguments);
    }
265906
public function setArguments(array $arguments)
    {
    	foreach ($arguments as $k => $v) {
    		$this->arguments[$k] = $v;
    	}
        
        return $this;
    }
559209
protected function mapArguments(array $arguments)
    {
        $keys = isset($this->mappableArguments[$this->element()]) ? $this->mappableArguments[$this->element()] : [];

        return array_combine(array_slice($keys, 0, count($arguments)), $arguments);
    }
587911
private function processArguments(array $arguments)
    {
        foreach ($arguments as $k => $argument) {
            if (is_array($argument)) {
                $arguments[$k] = $this->processArguments($argument);
            } elseif ($argument instanceof Reference) {
                $defId = $this->getDefinitionId($id = (string) $argument);

                if ($defId !== $id) {
                    $arguments[$k] = new Reference($defId, $argument->getInvalidBehavior());
                }
            }
        }

        return $arguments;
    }
545575
protected function _parseArguments($arguments) {
		$words = null;
		$function = $arguments[0];
		unset($arguments[0]);
		if (!in_array($function, array_merge($this->validMethods, ['all']))) {
			$function = $this->_getMethod();
		}

		$arguments = array_reverse($arguments);
		if (count($arguments) == 0) {
			$words = $this->_getWords();
		} else {
			while (count($arguments) > 0) {
				$words .= array_pop($arguments);
				if (count($arguments) > 0) {
					$words .= ' ';
				}
			}
		}

		return ['method' => $function, 'words' => $words];
	}
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);
    }
1011677
private function escape(array $arguments)
    {
        $args = array();
        foreach ($arguments as $k => $v) {
            if (is_array($v)) {
                $args[$k] = $this->escape($v);
            } elseif (is_string($v)) {
                $args[$k] = str_replace('%', '%%', $v);
            } else {
                $args[$k] = $v;
            }
        }

        return $args;
    }
261175
protected function getKeyArguments($arguments)
    {
        $keys = [];
        foreach ($arguments as $argument) {
            if (is_array($argument)) {
                $keys = array_merge($keys, $this->getKeyArguments($argument));
            }
            if (is_string($argument)) {
                $keys = array_merge($keys, $this->parseKeysString($argument));
            }
        }

        return $keys;
    }
310142
public function setCommandArguments(array $arguments)
    {
        $orderedArguments = [];
        foreach ($arguments as $index => $argument) {
            if (!($argument instanceof Parameter\Argument)) {
                throw new \Parable\Console\Exception(
                    "Arguments must be instances of Parameter\\Argument. The item at index {$index} is not."
                );
            }

            $argument->setOrder($index);
            $orderedArguments[$index] = $argument;
        }
        $this->commandArguments = $orderedArguments;

        return $this;
    }
30875
protected function removeTrailingArguments(array $arguments)
    {
        $trailing = array_splice($arguments, array_search('--', $arguments));
        array_shift($trailing);
        $this->trailing = implode(' ', $trailing);

        return $arguments;
    }