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

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

Methods

__construct()

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

An array of InputArgument and InputOption instance

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

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

getArgumentCount()

Returns the number of InputArguments.

public getArgumentCount() : int
Return values
int

getArgumentDefaults()

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
int

getOptionDefaults()

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>

getSynopsis()

Gets the synopsis.

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

hasArgument()

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

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

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

hasShortcut()

Returns true if an InputOption object exists by shortcut.

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

setArguments()

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


        
On this page

Search results