class InputDefinition
A InputDefinition represents a set of valid command line arguments and options.
Usage:
$definition = new InputDefinition(array(
new InputArgument('name', InputArgument::REQUIRED),
new InputOption('foo', 'f', InputOption::VALUE_REQUIRED),
));
__construct(array $definition = array()) | ||
setDefinition(array $definition) Sets the definition of the input. | ||
setArguments(InputArgument[] $arguments = array()) Sets the InputArgument objects. | ||
addArguments(InputArgument[] $arguments = array()) Adds an array of InputArgument objects. | ||
addArgument(InputArgument $argument) | ||
InputArgument | getArgument(string|int $name) Returns an InputArgument by name or by position. | |
bool | hasArgument(string|int $name) Returns true if an InputArgument object exists by name or position. | |
InputArgument[] | getArguments() Gets the array of InputArgument objects. | |
int | getArgumentCount() Returns the number of InputArguments. | |
int | getArgumentRequiredCount() Returns the number of required InputArguments. | |
array | getArgumentDefaults() Gets the default values. | |
setOptions(InputOption[] $options = array()) Sets the InputOption objects. | ||
addOptions(InputOption[] $options = array()) Adds an array of InputOption objects. | ||
addOption(InputOption $option) | ||
InputOption | getOption(string $name) Returns an InputOption by name. | |
bool | hasOption(string $name) Returns true if an InputOption object exists by name. | |
InputOption[] | getOptions() Gets the array of InputOption objects. | |
bool | hasShortcut(string $name) Returns true if an InputOption object exists by shortcut. | |
InputOption | getOptionForShortcut(string $shortcut) Gets an InputOption by shortcut. | |
array | getOptionDefaults() Gets an array of default values. | |
string | getSynopsis(bool $short = false) Gets the synopsis. |
array | $definition | An array of InputArgument and InputOption instance |
Sets the definition of the input.
array | $definition |
Sets the InputArgument objects.
InputArgument[] | $arguments | An array of InputArgument objects |
Adds an array of InputArgument objects.
InputArgument[] | $arguments | An array of InputArgument objects |
InputArgument | $argument |
LogicException | When incorrect argument is given |
Returns an InputArgument by name or by position.
string|int | $name | The InputArgument name or position |
InputArgument | An InputArgument object |
InvalidArgumentException | When argument given doesn't exist |
Returns true if an InputArgument object exists by name or position.
string|int | $name | The InputArgument name or position |
bool | true if the InputArgument object exists, false otherwise |
Gets the array of InputArgument objects.
InputArgument[] | An array of InputArgument objects |
Returns the number of InputArguments.
int | The number of InputArguments |
Returns the number of required InputArguments.
int | The number of required InputArguments |
Gets the default values.
array | An array of default values |
Sets the InputOption objects.
InputOption[] | $options | An array of InputOption objects |
Adds an array of InputOption objects.
InputOption[] | $options | An array of InputOption objects |
InputOption | $option |
LogicException | When option given already exist |
Returns an InputOption by name.
string | $name | The InputOption name |
InputOption | A InputOption object |
InvalidArgumentException | When option given doesn't exist |
Returns true if an InputOption object exists by name.
This method can't be used to check if the user included the option when executing the command (use getOption() instead).
string | $name | The InputOption name |
bool | true if the InputOption object exists, false otherwise |
Gets the array of InputOption objects.
InputOption[] | An array of InputOption objects |
Returns true if an InputOption object exists by shortcut.
string | $name | The InputOption shortcut |
bool | true if the InputOption object exists, false otherwise |
Gets an InputOption by shortcut.
string | $shortcut | The Shortcut name |
InputOption | An InputOption object |
Gets an array of default values.
array | An array of all default values |
Gets the synopsis.
bool | $short | Whether to return the short version (with options folded) or not |
string | The synopsis |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/Console/Input/InputDefinition.html