function ArrayInput::addLongOption
Adds a long option value.
Throws
InvalidOptionException When option given doesn't exist
InvalidOptionException When a required value is missing
2 calls to ArrayInput::addLongOption()
- ArrayInput::addShortOption in vendor/
symfony/ console/ Input/ ArrayInput.php - Adds a short option value.
- ArrayInput::parse in vendor/
symfony/ console/ Input/ ArrayInput.php - Processes command line arguments.
File
-
vendor/
symfony/ console/ Input/ ArrayInput.php, line 150
Class
- ArrayInput
- ArrayInput represents an input provided as an array.
Namespace
Symfony\Component\Console\InputCode
private function addLongOption(string $name, mixed $value) : void {
if (!$this->definition
->hasOption($name)) {
if (!$this->definition
->hasNegation($name)) {
throw new InvalidOptionException(\sprintf('The "--%s" option does not exist.', $name));
}
$optionName = $this->definition
->negationToName($name);
$this->options[$optionName] = false;
return;
}
$option = $this->definition
->getOption($name);
if (null === $value) {
if ($option->isValueRequired()) {
throw new InvalidOptionException(\sprintf('The "--%s" option requires a value.', $name));
}
if (!$option->isValueOptional()) {
$value = true;
}
}
$this->options[$name] = $value;
}