Documentation

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
author

Fabien Potencier fabien@symfony.com

Table of Contents

$arguments  : mixed
$lastArrayArgument  : mixed
$lastOptionalArgument  : mixed
$negations  : mixed
$options  : mixed
$requiredCount  : mixed
$shortcuts  : mixed
__construct()  : mixed
addArgument()  : mixed
addArguments()  : mixed
Adds an array of InputArgument objects.
addOption()  : mixed
addOptions()  : mixed
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, mixed>
Gets the default values.
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, mixed>
Gets an array of default values.
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()  : mixed
Sets the InputArgument objects.
setDefinition()  : mixed
Sets the definition of the input.
setOptions()  : mixed
Sets the InputOption objects.

Properties

Methods

__construct()

public __construct([array<string|int, mixed> $definition = [] ]) : mixed
Parameters
$definition : array<string|int, mixed> = []

An array of InputArgument and InputOption instance

Return values
mixed

addArguments()

Adds an array of InputArgument objects.

public addArguments([array<string|int, InputArgument$arguments = [] ]) : mixed
Parameters
$arguments : array<string|int, InputArgument> = []

An array of InputArgument objects

Return values
mixed

addOptions()

Adds an array of InputOption objects.

public addOptions([array<string|int, InputOption$options = [] ]) : mixed
Parameters
$options : array<string|int, InputOption> = []

An array of InputOption objects

Return values
mixed

getArgumentCount()

Returns the number of InputArguments.

public getArgumentCount() : int
Return values
int

The number of InputArguments

getArgumentDefaults()

Gets the default values.

public getArgumentDefaults() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array of default values

getArgumentRequiredCount()

Returns the number of required InputArguments.

public getArgumentRequiredCount() : int
Return values
int

The number of required InputArguments

getArguments()

Gets the array of InputArgument objects.

public getArguments() : array<string|int, InputArgument>
Return values
array<string|int, InputArgument>

An array of InputArgument objects

getOptionDefaults()

Gets an array of default values.

public getOptionDefaults() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array of all default values

getOptionForShortcut()

Gets an InputOption by shortcut.

public getOptionForShortcut(string $shortcut) : InputOption
Parameters
$shortcut : string
Return values
InputOption

An InputOption object

getOptions()

Gets the array of InputOption objects.

public getOptions() : array<string|int, InputOption>
Return values
array<string|int, InputOption>

An array of InputOption objects

getSynopsis()

Gets the synopsis.

public getSynopsis([bool $short = false ]) : string
Parameters
$short : bool = false
Return values
string

The synopsis

hasArgument()

Returns true if an InputArgument object exists by name or position.

public hasArgument(string|int $name) : bool
Parameters
$name : string|int

The InputArgument name or position

Return values
bool

true if the InputArgument object exists, false otherwise

hasNegation()

Returns true if an InputOption object exists by negated name.

public hasNegation(string $name) : bool
Parameters
$name : string
Return values
bool

hasOption()

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
bool

true if the InputOption object exists, false otherwise

hasShortcut()

Returns true if an InputOption object exists by shortcut.

public hasShortcut(string $name) : bool
Parameters
$name : string
Return values
bool

true if the InputOption object exists, false otherwise

setArguments()

Sets the InputArgument objects.

public setArguments([array<string|int, InputArgument$arguments = [] ]) : mixed
Parameters
$arguments : array<string|int, InputArgument> = []

An array of InputArgument objects

Return values
mixed

setDefinition()

Sets the definition of the input.

public setDefinition(array<string|int, mixed> $definition) : mixed
Parameters
$definition : array<string|int, mixed>
Return values
mixed

setOptions()

Sets the InputOption objects.

public setOptions([array<string|int, InputOption$options = [] ]) : mixed
Parameters
$options : array<string|int, InputOption> = []

An array of InputOption objects

Return values
mixed

Search results