Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ArrayInput.php

function ArrayInput::__toString

Returns a stringified representation of the args passed to the command.

Overrides InputInterface::__toString

File

vendor/symfony/console/Input/ArrayInput.php, line 93

Class

ArrayInput
ArrayInput represents an input provided as an array.

Namespace

Symfony\Component\Console\Input

Code

public function __toString() : string {
    $params = [];
    foreach ($this->parameters as $param => $val) {
        if ($param && \is_string($param) && '-' === $param[0]) {
            $glue = '-' === $param[1] ? '=' : ' ';
            if (\is_array($val)) {
                foreach ($val as $v) {
                    $params[] = $param . ('' != $v ? $glue . $this->escapeToken($v) : '');
                }
            }
            else {
                $params[] = $param . ('' != $val ? $glue . $this->escapeToken($val) : '');
            }
        }
        else {
            $params[] = \is_array($val) ? implode(' ', array_map($this->escapeToken(...), $val)) : $this->escapeToken($val);
        }
    }
    return implode(' ', $params);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal