InputDefinition
in package
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), ]);
Tags
Table of Contents
Properties
- $arguments : array<string|int, mixed>
- $lastArrayArgument : InputArgument|null
- $lastOptionalArgument : InputArgument|null
- $negations : array<string|int, mixed>
- $options : array<string|int, mixed>
- $requiredCount : int
- $shortcuts : array<string|int, mixed>
Methods
- __construct() : mixed
- addArgument() : void
- addArguments() : void
- Adds an array of InputArgument objects.
- addOption() : void
- addOptions() : void
- Adds an array of InputOption objects.
- getArgument() : InputArgument
- Returns an InputArgument by name or by position.
- getArgumentCount() : int
- Returns the number of InputArguments.
- getArgumentDefaults() : array<string|int, string|bool|int|float|array<string|int, mixed>|null>
- getArgumentRequiredCount() : int
- Returns the number of required InputArguments.
- getArguments() : array<string|int, InputArgument>
- Gets the array of InputArgument objects.
- getOption() : InputOption
- Returns an InputOption by name.
- getOptionDefaults() : array<string|int, string|bool|int|float|array<string|int, mixed>|null>
- getOptionForShortcut() : InputOption
- Gets an InputOption by shortcut.
- getOptions() : array<string|int, InputOption>
- Gets the array of InputOption objects.
- getSynopsis() : string
- Gets the synopsis.
- hasArgument() : bool
- Returns true if an InputArgument object exists by name or position.
- hasNegation() : bool
- Returns true if an InputOption object exists by negated name.
- hasOption() : bool
- Returns true if an InputOption object exists by name.
- hasShortcut() : bool
- Returns true if an InputOption object exists by shortcut.
- setArguments() : void
- Sets the InputArgument objects.
- setDefinition() : void
- Sets the definition of the input.
- setOptions() : void
- Sets the InputOption objects.
Properties
$arguments
private
array<string|int, mixed>
$arguments
= []
$lastArrayArgument
private
InputArgument|null
$lastArrayArgument
= null
$lastOptionalArgument
private
InputArgument|null
$lastOptionalArgument
= null
$negations
private
array<string|int, mixed>
$negations
= []
$options
private
array<string|int, mixed>
$options
= []
$requiredCount
private
int
$requiredCount
= 0
$shortcuts
private
array<string|int, mixed>
$shortcuts
= []
Methods
__construct()
public
__construct([array<string|int, mixed> $definition = [] ]) : mixed
Parameters
- $definition : array<string|int, mixed> = []
-
An array of InputArgument and InputOption instance
addArgument()
public
addArgument(InputArgument $argument) : void
Parameters
- $argument : InputArgument
Tags
addArguments()
Adds an array of InputArgument objects.
public
addArguments([array<string|int, InputArgument> $arguments = [] ]) : void
Parameters
- $arguments : array<string|int, InputArgument> = []
-
An array of InputArgument objects
addOption()
public
addOption(InputOption $option) : void
Parameters
- $option : InputOption
Tags
addOptions()
Adds an array of InputOption objects.
public
addOptions([array<string|int, InputOption> $options = [] ]) : void
Parameters
- $options : array<string|int, InputOption> = []
-
An array of InputOption objects
getArgument()
Returns an InputArgument by name or by position.
public
getArgument(string|int $name) : InputArgument
Parameters
- $name : string|int
Tags
Return values
InputArgumentgetArgumentCount()
Returns the number of InputArguments.
public
getArgumentCount() : int
Return values
intgetArgumentDefaults()
public
getArgumentDefaults() : array<string|int, string|bool|int|float|array<string|int, mixed>|null>
Return values
array<string|int, string|bool|int|float|array<string|int, mixed>|null>getArgumentRequiredCount()
Returns the number of required InputArguments.
public
getArgumentRequiredCount() : int
Return values
intgetArguments()
Gets the array of InputArgument objects.
public
getArguments() : array<string|int, InputArgument>
Return values
array<string|int, InputArgument>getOption()
Returns an InputOption by name.
public
getOption(string $name) : InputOption
Parameters
- $name : string
Tags
Return values
InputOptiongetOptionDefaults()
public
getOptionDefaults() : array<string|int, string|bool|int|float|array<string|int, mixed>|null>
Return values
array<string|int, string|bool|int|float|array<string|int, mixed>|null>getOptionForShortcut()
Gets an InputOption by shortcut.
public
getOptionForShortcut(string $shortcut) : InputOption
Parameters
- $shortcut : string
Return values
InputOptiongetOptions()
Gets the array of InputOption objects.
public
getOptions() : array<string|int, InputOption>
Return values
array<string|int, InputOption>getSynopsis()
Gets the synopsis.
public
getSynopsis([bool $short = false ]) : string
Parameters
- $short : bool = false
Return values
stringhasArgument()
Returns true if an InputArgument object exists by name or position.
public
hasArgument(string|int $name) : bool
Parameters
- $name : string|int
Return values
boolhasNegation()
Returns true if an InputOption object exists by negated name.
public
hasNegation(string $name) : bool
Parameters
- $name : string
Return values
boolhasOption()
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
- $name : string
Return values
boolhasShortcut()
Returns true if an InputOption object exists by shortcut.
public
hasShortcut(string $name) : bool
Parameters
- $name : string
Return values
boolsetArguments()
Sets the InputArgument objects.
public
setArguments([array<string|int, InputArgument> $arguments = [] ]) : void
Parameters
- $arguments : array<string|int, InputArgument> = []
-
An array of InputArgument objects
setDefinition()
Sets the definition of the input.
public
setDefinition(array<string|int, mixed> $definition) : void
Parameters
- $definition : array<string|int, mixed>
setOptions()
Sets the InputOption objects.
public
setOptions([array<string|int, InputOption> $options = [] ]) : void
Parameters
- $options : array<string|int, InputOption> = []
-
An array of InputOption objects