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

Breadcrumb

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

function InputDefinition::getArgument

Returns an InputArgument by name or by position.

Throws

InvalidArgumentException When argument given doesn't exist

File

vendor/symfony/console/Input/InputDefinition.php, line 129

Class

InputDefinition
A InputDefinition represents a set of valid command line arguments and options.

Namespace

Symfony\Component\Console\Input

Code

public function getArgument(string|int $name) : InputArgument {
    if (!$this->hasArgument($name)) {
        throw new InvalidArgumentException(\sprintf('The "%s" argument does not exist.', $name));
    }
    $arguments = \is_int($name) ? array_values($this->arguments) : $this->arguments;
    return $arguments[$name];
}
RSS feed
Powered by Drupal