Editor PHP 2.4.0

InputArgument
in package

Represents a command line argument.

Tags
author

Fabien Potencier fabien@symfony.com

Table of Contents

Constants

IS_ARRAY  = 4
The argument accepts multiple values and turn them into an array (e.g. 'app:foo bar baz' will result in value ['bar', 'baz']).
OPTIONAL  = 2
Providing an argument is optional (e.g. 'app:foo' and 'app:foo bar' are both allowed). This is the default behavior of arguments.
REQUIRED  = 1
Providing an argument is required (e.g. just 'app:foo' is not allowed).

Methods

__construct()  : mixed
complete()  : void
Supplies suggestions when command resolves possible completion options for input.
getDefault()  : string|bool|int|float|array<string|int, mixed>|null
Returns the default value.
getDescription()  : string
Returns the description text.
getName()  : string
Returns the argument name.
hasCompletion()  : bool
Returns true if the argument has values for input completion.
isArray()  : bool
Returns true if the argument can take multiple values.
isRequired()  : bool
Returns true if the argument is required.
setDefault()  : void
Sets the default value.

Constants

IS_ARRAY

The argument accepts multiple values and turn them into an array (e.g. 'app:foo bar baz' will result in value ['bar', 'baz']).

public mixed IS_ARRAY = 4

OPTIONAL

Providing an argument is optional (e.g. 'app:foo' and 'app:foo bar' are both allowed). This is the default behavior of arguments.

public mixed OPTIONAL = 2

REQUIRED

Providing an argument is required (e.g. just 'app:foo' is not allowed).

public mixed REQUIRED = 1

Methods

__construct()

public __construct(string $name[, int|null $mode = null ][, string $description = '' ][, string|bool|int|float|array<string|int, mixed>|null $default = null ][, array<string|int, mixed>|callable(CompletionInput, CompletionSuggestions): array<int, string|Suggestion$suggestedValues = [] ]) : mixed
Parameters
$name : string

The argument name

$mode : int|null = null
$description : string = ''

A description text

$default : string|bool|int|float|array<string|int, mixed>|null = null

The default value (for self::OPTIONAL mode only)

$suggestedValues : array<string|int, mixed>|callable(CompletionInput, CompletionSuggestions): array<int, string|Suggestion> = []

The values used for input completion

Tags
throws
InvalidArgumentException

When argument mode is not valid

getDefault()

Returns the default value.

public getDefault() : string|bool|int|float|array<string|int, mixed>|null
Return values
string|bool|int|float|array<string|int, mixed>|null

getDescription()

Returns the description text.

public getDescription() : string
Return values
string

getName()

Returns the argument name.

public getName() : string
Return values
string

hasCompletion()

Returns true if the argument has values for input completion.

public hasCompletion() : bool
Return values
bool

isArray()

Returns true if the argument can take multiple values.

public isArray() : bool
Return values
bool

true if mode is self::IS_ARRAY, false otherwise

isRequired()

Returns true if the argument is required.

public isRequired() : bool
Return values
bool

true if parameter mode is self::REQUIRED, false otherwise

setDefault()

Sets the default value.

public setDefault(string|bool|int|float|array<string|int, mixed>|null $default) : void
Parameters
$default : string|bool|int|float|array<string|int, mixed>|null

        
On this page

Search results