A InputDefinition represents a set of valid command line arguments and options.
Usage:
$definition = new InputDefinition([ new InputArgument('name', InputArgument::REQUIRED), new InputOption('foo', 'f', InputOption::VALUE_REQUIRED), ]);
- Full name:
\Symfony\Component\Console\Input\InputDefinition
private $arguments
private $requiredCount
private $lastArrayArgument
private $lastOptionalArgument
private $options
private $negations
private $shortcuts
public __construct(array $definition = []): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$definition |
array | An array of InputArgument and InputOption instance |
Sets the definition of the input.
public setDefinition(array $definition): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$definition |
array |
Sets the InputArgument objects.
public setArguments(\Symfony\Component\Console\Input\InputArgument[] $arguments = []): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$arguments |
\Symfony\Component\Console\Input\InputArgument[] | An array of InputArgument objects |
Adds an array of InputArgument objects.
public addArguments(\Symfony\Component\Console\Input\InputArgument[] $arguments = []): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$arguments |
\Symfony\Component\Console\Input\InputArgument[] | An array of InputArgument objects |
public addArgument(\Symfony\Component\Console\Input\InputArgument $argument): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$argument |
\Symfony\Component\Console\Input\InputArgument |
Returns an InputArgument by name or by position.
public getArgument(string|int $name): \Symfony\Component\Console\Input\InputArgument
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
string|int | The InputArgument name or position |
Returns true if an InputArgument object exists by name or position.
public hasArgument(string|int $name): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
string|int | The InputArgument name or position |
Gets the array of InputArgument objects.
public getArguments(): \Symfony\Component\Console\Input\InputArgument[]
Returns the number of InputArguments.
public getArgumentCount(): int
Returns the number of required InputArguments.
public getArgumentRequiredCount(): int
public getArgumentDefaults(): (string|bool|int|float|array|null)[]
Sets the InputOption objects.
public setOptions(\Symfony\Component\Console\Input\InputOption[] $options = []): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$options |
\Symfony\Component\Console\Input\InputOption[] | An array of InputOption objects |
Adds an array of InputOption objects.
public addOptions(\Symfony\Component\Console\Input\InputOption[] $options = []): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$options |
\Symfony\Component\Console\Input\InputOption[] | An array of InputOption objects |
public addOption(\Symfony\Component\Console\Input\InputOption $option): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$option |
\Symfony\Component\Console\Input\InputOption |
Returns an InputOption by name.
public getOption(string $name): \Symfony\Component\Console\Input\InputOption
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
string |
Returns true if an InputOption object exists by name.
public hasOption(string $name): bool
This method can't be used to check if the user included the option when executing the command (use getOption() instead).
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
string |
Gets the array of InputOption objects.
public getOptions(): \Symfony\Component\Console\Input\InputOption[]
Returns true if an InputOption object exists by shortcut.
public hasShortcut(string $name): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
string |
Returns true if an InputOption object exists by negated name.
public hasNegation(string $name): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$name |
string |
Gets an InputOption by shortcut.
public getOptionForShortcut(string $shortcut): \Symfony\Component\Console\Input\InputOption
Parameters:
Parameter | Type | Description |
---|---|---|
$shortcut |
string |
public getOptionDefaults(): (string|bool|int|float|array|null)[]
Gets the synopsis.
public getSynopsis(bool $short = false): string
Parameters:
Parameter | Type | Description |
---|---|---|
$short |
bool |