SymfonyComponentConsoleInputInputDefinition

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),
));
File
vendorSymfonyComponentConsoleInputInputDefinition.php
Package
Default
Class hierarchy
SymfonyComponentConsoleInputInputDefinition

Tags

author

Fabien Potencier fabien@symfony.com

api

Properties

$arguments

$arguments : 

Type

Tags

None found

$requiredCount

$requiredCount : 

Type

Tags

None found

$hasAnArrayArgument

$hasAnArrayArgument : 

Type

Tags

None found

$hasOptional

$hasOptional : 

Type

Tags

None found

$options

$options : 

Type

Tags

None found

$shortcuts

$shortcuts : 

Type

Tags

None found

Methods

__construct()

__construct(array  $definition = array()) 

Constructor.

Parameters

array $definition

An array of InputArgument and InputOption instance

Tags

api

setDefinition()

setDefinition(array  $definition) 

Sets the definition of the input.

Parameters

array $definition

The definition array

Tags

api

setArguments()

setArguments(array  $arguments = array()) 

Sets the InputArgument objects.

Parameters

array $arguments

An array of InputArgument objects

Tags

api

addArguments()

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

Adds an array of InputArgument objects.

Parameters

array<mixed,SymfonyComponentConsoleInputInputArgument> $arguments

An array of InputArgument objects

Tags

api

addArgument()

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

Adds an InputArgument object.

Parameters

SymfonyComponentConsoleInputInputArgument $argument

An InputArgument object

Throws

LogicException

When incorrect argument is given

Tags

api

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

InvalidArgumentException

When argument given doesn't exist

Returns

SymfonyComponentConsoleInputInputArgument

An InputArgument object

Tags

api

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

Tags

api

getArguments()

getArguments() : array

Gets the array of InputArgument objects.

Returns

array —

An array of InputArgument objects

Tags

api

getArgumentCount()

getArgumentCount() : integer

Returns the number of InputArguments.

Returns

integer —

The number of InputArguments

Tags

None found

getArgumentRequiredCount()

getArgumentRequiredCount() : integer

Returns the number of required InputArguments.

Returns

integer —

The number of required InputArguments

Tags

None found

getArgumentDefaults()

getArgumentDefaults() : array

Gets the default values.

Returns

array —

An array of default values

Tags

None found

setOptions()

setOptions(array  $options = array()) 

Sets the InputOption objects.

Parameters

array $options

An array of InputOption objects

Tags

api

addOptions()

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

Adds an array of InputOption objects.

Parameters

array<mixed,SymfonyComponentConsoleInputInputOption> $options

An array of InputOption objects

Tags

api

addOption()

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

Adds an InputOption object.

Parameters

SymfonyComponentConsoleInputInputOption $option

An InputOption object

Throws

LogicException

When option given already exist

Tags

api

getOption()

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

Returns an InputOption by name.

Parameters

string $name

The InputOption name

Returns

SymfonyComponentConsoleInputInputOption

A InputOption object

Tags

api

hasOption()

hasOption(string  $name) : Boolean

Returns true if an InputOption object exists by name.

Parameters

string $name

The InputOption name

Returns

Boolean —

true if the InputOption object exists, false otherwise

Tags

api

getOptions()

getOptions() : array

Gets the array of InputOption objects.

Returns

array —

An array of InputOption objects

Tags

api

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

Tags

None found

getOptionForShortcut()

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

Gets an InputOption by shortcut.

Parameters

string $shortcut

the Shortcut name

Returns

SymfonyComponentConsoleInputInputOption

An InputOption object

Tags

None found

getOptionDefaults()

getOptionDefaults() : array

Gets an array of default values.

Returns

array —

An array of all default values

Tags

None found

getSynopsis()

getSynopsis() : string

Gets the synopsis.

Returns

string —

The synopsis

Tags

None found

asText()

asText() : string

Returns a textual representation of the InputDefinition.

Returns

string —

A string representing the InputDefinition

Tags

None found

asXml()

asXml(Boolean  $asDom = false) : string|\Symfony\Component\Console\Input\DOMDocument

Returns an XML representation of the InputDefinition.

Parameters

Boolean $asDom

Whether to return a DOM or an XML string

Returns

string|SymfonyComponentConsoleInputDOMDocument —

An XML string representing the InputDefinition

Tags

None found

shortcutToName()

shortcutToName(string  $shortcut) : string

Returns the InputOption name given a shortcut.

Parameters

string $shortcut

The shortcut

Throws

InvalidArgumentException

When option given does not exist

Returns

string —

The InputOption name

Tags

None found

formatDefaultValue()

formatDefaultValue(  $default) 

Parameters

$default

Tags

None found