Documentation

InputOption
in package

Represents a command line option.

Tags
author

Fabien Potencier fabien@symfony.com

Table of Contents

Constants

VALUE_IS_ARRAY  = 8
The option accepts multiple values (e.g. --dir=/foo --dir=/bar).
VALUE_NONE  = 1
Do not accept input for the option (e.g. --yell). This is the default behavior of options.
VALUE_OPTIONAL  = 4
The option may or may not have a value (e.g. --yell or --yell=loud).
VALUE_REQUIRED  = 2
A value must be passed when the option is used (e.g. --iterations=5 or -i5).

Properties

$default  : mixed
$description  : mixed
$mode  : mixed
$name  : mixed
$shortcut  : mixed

Methods

__construct()  : mixed
acceptValue()  : bool
Returns true if the option accepts a value.
equals()  : bool
Checks whether the given option equals this one.
getDefault()  : string|bool|int|float|array<string|int, mixed>|null
Returns the default value.
getDescription()  : string
Returns the description text.
getName()  : string
Returns the option name.
getShortcut()  : string|null
Returns the option shortcut.
isArray()  : bool
Returns true if the option can take multiple values.
isValueOptional()  : bool
Returns true if the option takes an optional value.
isValueRequired()  : bool
Returns true if the option requires a value.
setDefault()  : mixed

Constants

VALUE_IS_ARRAY

The option accepts multiple values (e.g. --dir=/foo --dir=/bar).

public mixed VALUE_IS_ARRAY = 8

VALUE_NONE

Do not accept input for the option (e.g. --yell). This is the default behavior of options.

public mixed VALUE_NONE = 1

VALUE_OPTIONAL

The option may or may not have a value (e.g. --yell or --yell=loud).

public mixed VALUE_OPTIONAL = 4

VALUE_REQUIRED

A value must be passed when the option is used (e.g. --iterations=5 or -i5).

public mixed VALUE_REQUIRED = 2

Properties

Methods

__construct()

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

The option name

$shortcut : string|array<string|int, mixed>|null = null

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

$mode : int|null = null

The option mode: One of the VALUE_* constants

$description : string = ''

A description text

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

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

Tags
throws
InvalidArgumentException

If option mode is invalid or incompatible

acceptValue()

Returns true if the option accepts a value.

public acceptValue() : bool
Return values
bool

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

equals()

Checks whether the given option equals this one.

public equals(self $option) : bool
Parameters
$option : self
Return values
bool

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

The description text

getName()

Returns the option name.

public getName() : string
Return values
string

The name

getShortcut()

Returns the option shortcut.

public getShortcut() : string|null
Return values
string|null

The shortcut

isArray()

Returns true if the option can take multiple values.

public isArray() : bool
Return values
bool

true if mode is self::VALUE_IS_ARRAY, false otherwise

isValueOptional()

Returns true if the option takes an optional value.

public isValueOptional() : bool
Return values
bool

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

isValueRequired()

Returns true if the option requires a value.

public isValueRequired() : bool
Return values
bool

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

setDefault()

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

        
On this page

Search results