Formats an array as a string.

@param array $args The argument array

@return string
487650
public function formatArgs($args)
    {
        $result = [];
        foreach ($args as $key => $item) {
            if ('object' === $item[0]) {
                $parts = explode('\\', $item[1]);
                $short = array_pop($parts);
                $formattedValue = sprintf('<em>object</em>(<abbr title="%s">%s</abbr>)', $item[1], $short);
            } elseif ('array' === $item[0]) {
                $formattedValue = sprintf('<em>array</em>(%s)', \is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
            } 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", '', htmlspecialchars(var_export($item[1], true), ENT_COMPAT | ENT_SUBSTITUTE, $this->charset));
            }

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

        return implode(', ', $result);
    }
1142145
public static function arguments($args)
    {
        $argList = '';

        // If its a string return it
        if (is_string($args)) {
            return $args;
        }

        // If its not an array, Houston, we have a problem
        if (!is_array($args)) {
            throw new InvalidArgumentException();
        }

        // Build the argument list
        foreach ($args as $arg => $val) {
            $argList .= ' ' . $arg;
            if (!empty($val)) {
                $argList .= ' ' . $val;
            }
        }

        return trim($argList);
    }
1119774
protected static function parseArguments(array $arguments) {
    $string = '';
    foreach ($arguments as $name => $value) {
      if (is_null($value)) {
        $string .= ' --' . $name;
      }
      else {
        $string .= ' --' . $name . '=' . $value;
      }
    }
    return $string;
  }
492427
private function parse_args($args = [])
    {
        $args['NAMESPACE'] = '';

        $class_name = $this->sanitise_filename($args['CLASSNAME']);

        if ($this->is_nested_directory($class_name)) {
            $parts = \explode('\\', $class_name);
            $class = \array_pop($parts);

            $args['NAMESPACE'] = '\\' . \implode('\\', $parts);
            $args['CLASSNAME'] = $class;
        }

        return $args;
    }
921413
public static function toString($args, $link  = '') {
		$str = '';
		if (is_array($args)) {
			foreach ($args as $value) {
				$str .= self::toString($value, $link);
			}
		} else {
			$str .= $args.$link;
		}
		return $str;
	}
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;
    }
931748
protected function getArgumentsAsString(array $args)
    {
        $result = [];
        $isNumeric = Jasny\is_numeric_array($args);
        $stringify = function ($input) {
            return sprintf("'%s'", addcslashes($input, "'"));
        };

        foreach ($args as $key => $arg) {
            switch (strtolower(gettype($arg))) {
                case 'string':
                    $string = $stringify($arg);
                    break;

                case 'object':
                    $string = get_class($arg);
                    break;

                case 'array':
                    $string = "[{$this->getArgumentsAsString($arg)}]";
                    break;

                case 'null':
                    $string = 'null';
                    break;

                case 'boolean':
                    $string = $arg ? 'true' : 'false';
                    break;

                case 'resource':
                    $string = sprintf('*%s', get_resource_type($arg));
                    break;

                default:
                    $string = $arg;
            }

            if ($isNumeric === false) {
                $result[] = is_string($key) === true ? $stringify($key) . ' => ' . $string : $string;
            } else {
                $result[] = $string;
            }
        }

        return join(', ', $result);
    }
689682
protected function formatLabel($arguments = [])
    {
        $column = is_array($this->column) ? current($this->column) : $this->column;

        $label = isset($arguments[0]) ? $arguments[0] : ucfirst($column);

        return str_replace(['.', '_'], ' ', $label);
    }
790295
public function prepareCommand($args)
    {
        $command = $this->getCommand();
        if (is_string($args)) {
            return $command . ' ' . trim($args);
        }

        foreach ($args as $arg) {
            if ($arg instanceof ModifierInterface) {
                $command = $arg->modify($command);
            } else {
                $command .= ' ' . escapeshellarg($arg);
            }
        }

        return $command;
    }
747560
public function decode(array $args)
    {
        $decoded = [];

        foreach ($args as $arg) {

            if (!is_string($arg)) {
                $decoded[] = $arg;
                continue;
            }

            $decoded[] = $this->deserialize($arg);

        }

        return $decoded;
    }
1262566
public function formatArgs($args)
    {
        // The first argument is always the file
        unset($args[0]);

        if (isset($args[1])) {
            $command = explode(':', $args[1]);
            unset($args[1]);
        } else {
            // No Command Specified.
            return array();
        }

        try {

            $action = (isset($command[1]) ? $command[1] : 'main');
            $cmd = $this->library->find($command[0].':'.$action);
            $task = get_class($cmd);

            return array(
                'task'      => $task,
                'action'    => $action,
                'params'    => $args
            );

        } catch (\Exception $e) {

            // No Command FOUND
            return array();
        }
    }
1139244
public static function _describeArg($arg)
    {
        if (is_array($arg)) {
            return sprintf('array[%d]', count($arg));
        }
        if (is_object($arg)) {
            return sprintf('object[%s]', get_class($arg));
        }

        return Text::toString($arg);
    }
509599
private function getParams(array $args)
    {
        if (count($args) == 0) {
            return [];
        }

        $params = array_slice($args, -1)[0];

        return is_array($params) ? $params : [];
    }
712844
protected function encodeArray(array $args): array
    {
        foreach ($args as $key => $value) {
            if (is_object($value)) {
                $args[$key] = get_class($value);
            }
        }
        return $args;
    }
1126795
public function selectOptions(array $args = []): string
    {
        // Establish args.

        $default_args = [
            // Unique.
            'allow_empty'      => true,
            'allow_arbitrary'  => true,
            'option_formatter' => null,
            'current_caps'     => null,

            // Used by {@link all()}.
            'max'         => 1000,
            'fail_on_max' => true,

            // Used by {@link total()}.
            // Used by {@link all()}.
            'include'                   => [],
            'exclude'                   => [],
            'exclude_deprecated_levels' => true,
            'no_cache'                  => false,
        ];
        $args = array_merge($default_args, $args);
        $args = array_intersect_key($args, $default_args);

        // Unique.
        $args['allow_empty']      = (bool) $args['allow_empty'];
        $args['allow_arbitrary']  = (bool) $args['allow_arbitrary'];
        $args['option_formatter'] = is_callable($args['option_formatter']) ? $args['option_formatter'] : null;
        $args['current_caps']     = isset($args['current_caps']) ? (array) $args['current_caps'] : null;
        $args['current_caps']     = $this->c::removeEmptys(array_map('strval', $args['current_caps']));

        // Used by {@link all()}.
        $args['max']         = max(1, (int) $args['max']);
        $args['fail_on_max'] = (bool) $args['fail_on_max'];

        // Used by {@link total()}.
        // Used by {@link all()}.
        $args['include']                   = (array) $args['include'];
        $args['exclude']                   = (array) $args['exclude'];
        $args['exclude_deprecated_levels'] = (bool) $args['exclude_deprecated_levels'];
        $args['no_cache']                  = (bool) $args['no_cache'];

        // Check for nothing being available (or too many).

        if (!($caps = $this->all($args))) {
            return ''; // None available.
        }
        // Initialize several working variables.

        $options        = ''; // Initialize.
        $available_caps = []; // Initialize.
        $selected_caps  = []; // Initialize.

        // Build & return all `<option>` tags.

        if ($args['allow_empty']) { // Allow ``?
            $options = '<option value=""></option>';
        }
        foreach ($caps as $_cap) { // Key/value the same at this time.
            $available_caps[] = $_cap; // Record all available.

            if (isset($args['current_caps']) && in_array($_cap, $args['current_caps'], true)) {
                $selected_caps[$_cap] = $_cap; // Flag selected cap.
            }
            $_cap_selected_attr = isset($selected_caps[$_cap]) ? ' selected' : '';

            // Format `<option>` tag w/ a custom formatter?

            if ($args['option_formatter']) {
                $options .= $args['option_formatter']($_cap, [
                        'cap_selected_attr' => $_cap_selected_attr,
                    ], $args); // ↑ This allows for a custom option formatter.
                    // The formatter must always return an `<option></option>` tag.

            // Else format the `<option>` tag using a default behavior.
            } else { // Both front & back-end displays are the same for caps.
                $options .= '<option value="'.esc_attr($_cap).'"'.$_cap_selected_attr.'>'.
                                esc_html($_cap).
                            '</option>';
            }
        } // unset($_cap, $_cap_selected_attr); // Housekeeping.

        if ($args['allow_arbitrary'] && $args['current_caps']) { // Allow arbitrary select `<option>`s?
            foreach (array_diff($args['current_caps'], $available_caps) as $_arbitrary_cap) {
                $options .= '<option value="'.esc_attr($_arbitrary_cap).'" selected>'.
                                esc_html($_arbitrary_cap).
                            '</option>';
            } // unset($_arbitrary_cap); // Housekeeping.
        }
        return $options; // HTML markup.
    }
387365
protected function parseId( array $args )
	{
		if( isset( $args['id'] ) && !$args['id'] )return;

		!$args['suffix'] ?: $args['suffix'] = "-{$args['suffix']}";

		return str_replace( ['[]','[',']','.'], ['','-','','-'], $this->parseName( $args ) . $args['suffix'] );
	}
268328
private function formatEcho(Format $format, $args)
    {
        foreach ($args as $group => $list) {
            if (is_array($list)) {
                $this->writeln($format->format($group));
                foreach ($list as $name => $desc) {
                    $this->writeln($format->format('  ' . $name . str_repeat(' ', $this->commandLength - 2 - strlen($name)) . $desc));
                }
            } else {
                $this->writeln($format->format($group . str_repeat(' ', $this->commandLength - strlen($group)) . $list));
            }
        }
    }