public function InputDefinition::addArgument in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/console/Input/InputDefinition.php \Symfony\Component\Console\Input\InputDefinition::addArgument()
Adds an InputArgument object.
Parameters
InputArgument $argument An InputArgument object:
Throws
\LogicException When incorrect argument is given
1 call to InputDefinition::addArgument()
- InputDefinition::addArguments in vendor/
symfony/ console/ Input/ InputDefinition.php - Adds an array of InputArgument objects.
File
- vendor/
symfony/ console/ Input/ InputDefinition.php, line 105
Class
- InputDefinition
- A InputDefinition represents a set of valid command line arguments and options.
Namespace
Symfony\Component\Console\InputCode
public function addArgument(InputArgument $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;
}