Creates an input argument for the given argument.

@param Argument $argument The argument.

@return InputArgument The created input argument.
543980
private function adaptArgument(Argument $argument)
    {
        $mode = null;

        if ($argument->isMultiValued()) {
            $mode |= InputArgument::IS_ARRAY;
        }

        if ($argument->isOptional()) {
            $mode |= InputArgument::OPTIONAL;
        }

        if ($argument->isRequired()) {
            $mode |= InputArgument::REQUIRED;
        }

        return new InputArgument($argument->getName(), $mode, $argument->getDescription(), $argument->getDefaultValue());
    }
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;
    }
992470
protected function createQueryForArguments($arguments)
    {
        $this->createQuery();

        // Build query string.
        $rawQueryParameters = [];
        if (array_key_exists('q', $arguments)) {
            $rawQueryParameters = $arguments['q'];
        }

        // Process parameters to eliminate empty values
        $queryParameters = [];
        if (is_array($rawQueryParameters) && $rawQueryParameters !== []) {
            foreach ($rawQueryParameters as $key => $value) {
                if (is_array($value) && count(array_filter($value)) > 0) {
                    $queryParameters[$key] = array_filter($value);
                } elseif (!empty($value) && !is_array($value)) {
                    $queryParameters[$key] = $value;
                }
            }
        }

        $queryComponents = $this->queryComponentsForQueryParameters($queryParameters);
        $queryString = implode(' '.Query::QUERY_OPERATOR_AND.' ', $queryComponents);

        $this->query->setQuery($queryString);

        $this->setConfigurationValue('query', $queryParameters);
        $this->setConfigurationValue('queryString', $queryString);

        $this->setFields($arguments);
        $this->setRange($arguments);
        $this->setSortOrder($arguments);

        $this->addHighlighting($arguments);
        $this->setConfigurationValue('activeFacets', $this->addFacetFilters($arguments));
        $this->addFacetQueries();
    }
969667
protected function create(...$arguments)
    {
        $response = null;
        while ($method = $this->methods->next($response)) {
            $response = call_user_func($method, ...$arguments);
        }

        return $response;
    }
1275587
protected function hasInputArgument($argument, $input)
    {
        return $input->hasArgument($argument) && null !== $input->getArgument($argument);
    }
333718
public function writeArgument(PhpArgument $argument)
    {
        try {
            $value = $argument->getValue();

            if ($argument->isVariableReference() === true) {
                $this->getStream()->write('$' . $value->getName());
            } else {
                $this->writeScalar($value);
            }
        } catch (StreamException $e) {
            $msg = "An error occured while writing an argument with value '${value}'.";
            throw new StreamAccessException($msg, $this, 0, $e);
        }
    }
495209
public function addArguments($arguments = [])
    {
        if (null !== $arguments) {
            foreach ($arguments as $argument) {
                $this->addArgument($argument);
            }
        }
    }
98010
protected function setArgumentValue($argv, $argument, $key, $value)
    {
        // Arguments are given the value true if they only need to
        // be defined on the command line to be set.
        if ($argument->noValue()) {
            $argument->setValue(true);
            return $argv;
        }

        if (is_null($value)) {
            if (count($argv) === 0) {
                return $argv;
            }

            // If the value wasn't previously defined in "key=value"
            // format then define it from the next command argument.
            $nextArgvValue = $argv[$key + 1];
            if ($this->isValidArgumentValue($nextArgvValue)) {
                $argument->setValue($nextArgvValue);
                unset($argv[$key + 1]);
                return $argv;
            }
        }

        $argument->setValue($value);

        return $argv;
    }
1022328
public function setArguments($arguments = array())
    {
        // add additional arguments
        if (!$arguments) {
            $arguments = array();
        }
        if (!is_array($arguments)) {
            throw new BaseException('Arguments must be always an array');
        }
        $this->arguments = $args = array_merge($this->arguments, $arguments);
        foreach ($args as $arg => $val) {
            if (is_null($val)) {
                unset($this->arguments[$arg]);
            }
        }

        return $this;
    }
1202060
public static function create(...$arguments)
    {
        trigger_error(__METHOD__.'() has been deprecated and will be removed from v2.', E_USER_DEPRECATED);

        if (isset($arguments[0]) && is_string($arguments[0])) {
            return new static([], $arguments[0], $arguments[1] ?? []);
        }

        return new static(...$arguments);
    }
1228146
public function setArgument($argument, $position = null)
    {
        array_splice($this->arguments, $position ?: count($this->arguments), 0, array($argument));

        return $this;
    }
246469
public function addArguments($arguments = [])
    {
        if (null !== $arguments) {
            foreach ($arguments as $argument) {
                $this->setArgument($argument);
            }
        }
    }
930005
public function addArgument(Argument $argument) {
        if (isset($this->arguments[$argument->getName()])) {
            throw new \LogicException(sprintf('An argument with name "%s" already exists.', $argument->getName()));
        }

        if ($this->hasAnArrayArgument) {
            throw new \LogicException('Cannot add an argument after an array argument.');
        }

        if ($argument->isRequired() && $this->hasOptional) {
            throw new \LogicException('Cannot add a required argument after an optional one.');
        }

        if ($argument->isArray()) {
            $this->hasAnArrayArgument = true;
        }

        if ($argument->isRequired()) {
            ++$this->requiredCount;
        }
        else {
            $this->hasOptional = true;
        }

        $this->arguments[$argument->getName()] = $argument;
    }
1301723
public function setArgument($num, $argument)
  {
    if ($this->isLocked()) {
      return $this->getObj()->setArgument($num, $argument)->setLocked();
    } else {
      return parent::setArgument($num, $argument);
    }
  }
1102702
public function removeArgument($argument)
    {
        if (true === isset($this->arguments[$argument])) {
            unset($this->arguments[$argument]);
        }
    }
521073
public function removeArgument($arg)
    {
        if ($this->hasArgument($arg)) {
            $this->arguments->remove($arg);
        }
        return $this;
    }
792783
public function addArguments(array $arguments)
    {
        foreach ($arguments as $param => $value) {
            $this->addArgument($param, $value);
        }

        return $this;
    }