\Symfony\Component\Console\InputInputDefinition

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),
));

Summary

Methods
Properties
Constants
__construct()
setDefinition()
setArguments()
addArguments()
addArgument()
getArgument()
hasArgument()
getArguments()
getArgumentCount()
getArgumentRequiredCount()
getArgumentDefaults()
setOptions()
addOptions()
addOption()
getOption()
hasOption()
getOptions()
hasShortcut()
getOptionForShortcut()
getOptionDefaults()
getSynopsis()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
shortcutToName()
$arguments
$requiredCount
$hasAnArrayArgument
$hasOptional
$options
$shortcuts
N/A

Properties

$arguments

$arguments : 

Type

$requiredCount

$requiredCount : 

Type

$hasAnArrayArgument

$hasAnArrayArgument : 

Type

$hasOptional

$hasOptional : 

Type

$options

$options : 

Type

$shortcuts

$shortcuts : 

Type

Methods

__construct()

__construct(array  $definition = array()) 

Parameters

array $definition

An array of InputArgument and InputOption instance

setDefinition()

setDefinition(array  $definition) 

Sets the definition of the input.

Parameters

array $definition

setArguments()

setArguments(array<mixed,\Symfony\Component\Console\Input\InputArgument>  $arguments = array()) 

Sets the InputArgument objects.

Parameters

array<mixed,\Symfony\Component\Console\Input\InputArgument> $arguments

An array of InputArgument objects

addArguments()

addArguments(array<mixed,\Symfony\Component\Console\Input\InputArgument>  $arguments = array()) 

Adds an array of InputArgument objects.

Parameters

array<mixed,\Symfony\Component\Console\Input\InputArgument> $arguments

An array of InputArgument objects

addArgument()

addArgument(\Symfony\Component\Console\Input\InputArgument  $argument) 

Parameters

\Symfony\Component\Console\Input\InputArgument $argument

Throws

\Symfony\Component\Console\Exception\LogicException

When incorrect argument is given

getArgument()

getArgument(string|integer  $name) : \Symfony\Component\Console\Input\InputArgument

Returns an InputArgument by name or by position.

Parameters

string|integer $name

The InputArgument name or position

Throws

\Symfony\Component\Console\Exception\InvalidArgumentException

When argument given doesn't exist

Returns

\Symfony\Component\Console\Input\InputArgument

An InputArgument object

hasArgument()

hasArgument(string|integer  $name) : boolean

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

Parameters

string|integer $name

The InputArgument name or position

Returns

boolean —

true if the InputArgument object exists, false otherwise

getArguments()

getArguments() : array<mixed,\Symfony\Component\Console\Input\InputArgument>

Gets the array of InputArgument objects.

Returns

array<mixed,\Symfony\Component\Console\Input\InputArgument> —

An array of InputArgument objects

getArgumentCount()

getArgumentCount() : integer

Returns the number of InputArguments.

Returns

integer —

The number of InputArguments

getArgumentRequiredCount()

getArgumentRequiredCount() : integer

Returns the number of required InputArguments.

Returns

integer —

The number of required InputArguments

getArgumentDefaults()

getArgumentDefaults() : array

Gets the default values.

Returns

array —

An array of default values

setOptions()

setOptions(array<mixed,\Symfony\Component\Console\Input\InputOption>  $options = array()) 

Sets the InputOption objects.

Parameters

array<mixed,\Symfony\Component\Console\Input\InputOption> $options

An array of InputOption objects

addOptions()

addOptions(array<mixed,\Symfony\Component\Console\Input\InputOption>  $options = array()) 

Adds an array of InputOption objects.

Parameters

array<mixed,\Symfony\Component\Console\Input\InputOption> $options

An array of InputOption objects

addOption()

addOption(\Symfony\Component\Console\Input\InputOption  $option) 

Parameters

\Symfony\Component\Console\Input\InputOption $option

Throws

\Symfony\Component\Console\Exception\LogicException

When option given already exist

getOption()

getOption(string  $name) : \Symfony\Component\Console\Input\InputOption

Returns an InputOption by name.

Parameters

string $name

The InputOption name

Throws

\Symfony\Component\Console\Exception\InvalidArgumentException

When option given doesn't exist

Returns

\Symfony\Component\Console\Input\InputOption

A InputOption object

hasOption()

hasOption(string  $name) : boolean

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).

Parameters

string $name

The InputOption name

Returns

boolean —

true if the InputOption object exists, false otherwise

getOptions()

getOptions() : array<mixed,\Symfony\Component\Console\Input\InputOption>

Gets the array of InputOption objects.

Returns

array<mixed,\Symfony\Component\Console\Input\InputOption> —

An array of InputOption objects

hasShortcut()

hasShortcut(string  $name) : boolean

Returns true if an InputOption object exists by shortcut.

Parameters

string $name

The InputOption shortcut

Returns

boolean —

true if the InputOption object exists, false otherwise

getOptionForShortcut()

getOptionForShortcut(string  $shortcut) : \Symfony\Component\Console\Input\InputOption

Gets an InputOption by shortcut.

Parameters

string $shortcut

The Shortcut name

Returns

\Symfony\Component\Console\Input\InputOption

An InputOption object

getOptionDefaults()

getOptionDefaults() : array

Gets an array of default values.

Returns

array —

An array of all default values

getSynopsis()

getSynopsis(boolean  $short = false) : string

Gets the synopsis.

Parameters

boolean $short

Whether to return the short version (with options folded) or not

Returns

string —

The synopsis

shortcutToName()

shortcutToName(string  $shortcut) : string

Returns the InputOption name given a shortcut.

Parameters

string $shortcut

The shortcut

Throws

\Symfony\Component\Console\Exception\InvalidArgumentException

When option given does not exist

Returns

string —

The InputOption name