Documentation

InputArgument
in package

Represents a command line argument.

Tags
author

Fabien Potencier fabien@symfony.com

Table of Contents

Constants

IS_ARRAY  = 4
OPTIONAL  = 2
REQUIRED  = 1

Properties

$default  : string|int|bool|array<string|int, mixed>|null|float
$description  : string
$mode  : int
$name  : string
$suggestedValues  : array<string|int, mixed>|Closure

Methods

__construct()  : mixed
complete()  : void
Adds suggestions to $suggestions for the current completion 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
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

Properties

$default

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

$suggestedValues

private array<string|int, mixed>|Closure $suggestedValues

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

The argument mode: a bit mask of self::REQUIRED, self::OPTIONAL and self::IS_ARRAY

$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()

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 = null ]) : void
Parameters
$default : string|bool|int|float|array<string|int, mixed>|null = null
Tags
throws
LogicException

When incorrect default value is given


        
On this page

Search results