\Symfony\Component\Console\InputInputOption

Represents a command line option.

Summary

Methods
Properties
Constants
__construct()
getShortcut()
getName()
acceptValue()
isValueRequired()
isValueOptional()
isArray()
setDefault()
getDefault()
getDescription()
equals()
No public properties found
VALUE_NONE
VALUE_REQUIRED
VALUE_OPTIONAL
VALUE_IS_ARRAY
No protected methods found
No protected properties found
N/A
No private methods found
$name
$shortcut
$mode
$default
$description
N/A

Constants

VALUE_NONE

VALUE_NONE = 1

VALUE_REQUIRED

VALUE_REQUIRED = 2

VALUE_OPTIONAL

VALUE_OPTIONAL = 4

VALUE_IS_ARRAY

VALUE_IS_ARRAY = 8

Properties

$name

$name : 

Type

$shortcut

$shortcut : 

Type

$mode

$mode : 

Type

$default

$default : 

Type

$description

$description : 

Type

Methods

__construct()

__construct(string  $name, string|array  $shortcut = null, integer|null  $mode = null, string  $description = '', string|array<mixed,string>|integer|boolean|null  $default = null) 

Parameters

string $name

The option name

string|array $shortcut

The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts

integer|null $mode

The option mode: One of the VALUE_* constants

string $description

A description text

string|array<mixed,string>|integer|boolean|null $default

The default value (must be null for self::VALUE_NONE)

Throws

\Symfony\Component\Console\Exception\InvalidArgumentException

If option mode is invalid or incompatible

getShortcut()

getShortcut() : string

Returns the option shortcut.

Returns

string —

The shortcut

getName()

getName() : string

Returns the option name.

Returns

string —

The name

acceptValue()

acceptValue() : boolean

Returns true if the option accepts a value.

Returns

boolean —

true if value mode is not self::VALUE_NONE, false otherwise

isValueRequired()

isValueRequired() : boolean

Returns true if the option requires a value.

Returns

boolean —

true if value mode is self::VALUE_REQUIRED, false otherwise

isValueOptional()

isValueOptional() : boolean

Returns true if the option takes an optional value.

Returns

boolean —

true if value mode is self::VALUE_OPTIONAL, false otherwise

isArray()

isArray() : boolean

Returns true if the option can take multiple values.

Returns

boolean —

true if mode is self::VALUE_IS_ARRAY, false otherwise

setDefault()

setDefault(string|array<mixed,string>|integer|boolean|null  $default = null) 

Sets the default value.

Parameters

string|array<mixed,string>|integer|boolean|null $default

The default value

Throws

\Symfony\Component\Console\Exception\LogicException

When incorrect default value is given

getDefault()

getDefault() : string|array<mixed,string>|integer|boolean|null

Returns the default value.

Returns

string|array<mixed,string>|integer|boolean|null —

The default value

getDescription()

getDescription() : string

Returns the description text.

Returns

string —

The description text

equals()

equals(self  $option) : boolean

Checks whether the given option equals this one.

Parameters

self $option

Returns

boolean